I just did the same in my code with version 6, but now I have the same problem with version 7.0 into another function.
I think a good solution would be moving every function (or macro) using such problematic form of initializers to .c files.
This is how I could solve the problem in lv_color.h with version 6:
#define LV_COLOR_WHITE lv_color_make(0xFF, 0xFF, 0xFF)
#define LV_COLOR_SILVER lv_color_make(0xC0, 0xC0, 0xC0)
#define LV_COLOR_GRAY lv_color_make(0x80, 0x80, 0x80)
#define LV_COLOR_BLACK lv_color_make(0x00, 0x00, 0x00)
#define LV_COLOR_RED lv_color_make(0xFF, 0x00, 0x00)
#define LV_COLOR_MAROON lv_color_make(0x80, 0x00, 0x00)
#define LV_COLOR_YELLOW lv_color_make(0xFF, 0xFF, 0x00)
#define LV_COLOR_OLIVE lv_color_make(0x80, 0x80, 0x00)
#define LV_COLOR_LIME lv_color_make(0x00, 0xFF, 0x00)
#define LV_COLOR_GREEN lv_color_make(0x00, 0x80, 0x00)
#define LV_COLOR_CYAN lv_color_make(0x00, 0xFF, 0xFF)
#define LV_COLOR_AQUA LV_COLOR_CYAN
#define LV_COLOR_TEAL lv_color_make(0x00, 0x80, 0x80)
#define LV_COLOR_BLUE lv_color_make(0x00, 0x00, 0xFF)
#define LV_COLOR_NAVY lv_color_make(0x00, 0x00, 0x80)
#define LV_COLOR_MAGENTA lv_color_make(0xFF, 0x00, 0xFF)
#define LV_COLOR_PURPLE lv_color_make(0x80, 0x00, 0x80)
#define LV_COLOR_ORANGE lv_color_make(0xFF, 0xA5, 0x00)
…
#if (0)
/* Fix by rnnslv: Commented out because of error C4576*/
/* The most simple macro to create a color from R,G and B values */
#if LV_COLOR_DEPTH == 1
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){.full = (uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))})
#elif LV_COLOR_DEPTH == 8
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}})
#elif LV_COLOR_DEPTH == 16
#if LV_COLOR_16_SWAP == 0
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x3FU), (uint16_t)((r8 >> 3) & 0x1FU)}})
#else
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)((g8 >> 5) & 0x7U), (uint16_t)((r8 >> 3) & 0x1FU), (uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x7U)}})
#endif
#elif LV_COLOR_DEPTH == 32
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /Fix 0xff alpha/
#endif
#endif
…
static inline lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b)
{
// return LV_COLOR_MAKE(r, g, b);
lv_color_t out;
#if LV_COLOR_DEPTH == 1
out.full = (b >> 7 | g >> 7 | r >> 7);
#elif LV_COLOR_DEPTH == 8
out.ch.blue = b >> 6;
out.ch.green = g >> 5;
out.ch.red = r >> 5;
#elif LV_COLOR_DEPTH == 16
#if LV_COLOR_16_SWAP == 0
out.ch.blue = b >> 3;
out.ch.green = g >> 2;
out.ch.red = r >> 3;
#else
out.ch.green_h = g >> 5;
out.ch.red = r >> 3;
out.ch.blue = b >> 3;
out.ch.green_l = (g >> 2) & 0x7;
#endif
#elif LV_COLOR_DEPTH == 32
out.ch.blue = b;
out.ch.green = g;
out.ch.red = r;
out.ch.alpha = 0xff; /Fix 0xff alpha/
#endif
return out;
}
But with version 7, I’m getting a new problem of the same kind inside the function “lv_color_mix_with_alpha”.
Any suggestion on how could I initialize the following vars in a legal and working way for all allowed color depths?
static lv_color_t fg_color_save = {.full = 0};
static lv_color_t bg_color_save = {.full = 0};
static lv_color_t res_color_saved = {.full = 0};
Anyway I’d be glad if this issue was solved on the master version.