It looks like that the combiler can not work with this combination of the macros. First I added brackets arround the second line to prevent missuse there. Second I replaced for tests FG_COLOR with a fix color LV_COLOR_WHITE. Now everything combiles but is not a nice solution.
I guess it has something to do with the compiler how and in which order the macros are interpreted. So, can this problem somehow be connected with our Renesas MCU? If yes, do we find a nice solution that works for all MCUs?
Has someone experience with LVGL and Renesas MCUs?
With the mentioned “work around” LVGL works flawlessly. But I would like to be able to upgrade LVGL later without making changes all the time to the library.
I think it would be mandadory (as good programming practice) to put parenthesis around a ternary expression (if it is not used standalone).
Of course it’s good practice to always put parenthesis around a macro expression if it contains more than a single element.
I’m absolutely with you and could be fixed in the LVGL library, but this for its own did not solve my problem. The error occurs when “COLOR_INV(BG_COLOR)” gets called.
@Night@robekras At first glance, this may be either a compiler bug, or some non-standard behavior on our part. LV_COLOR_WHITE and LV_COLOR_BLACK are macros which build a struct, not variables, something like this:
I’m not sure whether C allows you to access the members of a struct in the same statement it’s built in. Evidently, other compilers don’t have a problem with this, so I suspect the RX27N compiler may be noncompliant in this regard. However, it’s also possible that this is nonstandard, and other compilers just accept it.
I just reached out to Renesas via the Customer Hub.
After a few messages back and forth with a helpful support engineer he reached out to the company’s compiler team in Japan.
He then told me that the problem is in fact a bug in the CCRX compiler. So I guess it is safe to assume that the LVGL code in that specific file is standard and can be used like that.