Styles can be built as const too to save RAM: How to pass const in lv_obj_add_style?


assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

How to pass const in lv_obj_add_style? There are macros described in last part of Styles — LVGL documentation but there is no example of how to use them. Docs are quiet after this mention of their existance.

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

LV_STYLE_CONST_INIT(styl1, style);
lv_obj_add_style(obj1, &styl1, 0);
No warning becouse of const in makro

What have you tried so far?

lv_obj_add_style(obj1, (lv_style_t*)&styl1, 0);