Styles as const to save RAM. Gives error

Description

Building styles as const to save RAM gives this error:

note: expected '**lv_style_t ***' but argument is of type '**const lv_style_t ***'

void lv_obj_add_style(struct _lv_obj_t * obj, **lv_style_t * style**, lv_style_selector_t selector);

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

ESP32-S3 + ESP IDF

What LVGL version are you using?

8.3.9

What do you want to achieve?

Building style as const as described here

What have you tried so far?

Updated LVGL to latest Release 8.3.9

Code to reproduce

const lv_style_const_prop_t style1_props[] = {
   LV_STYLE_CONST_WIDTH(50),
   LV_STYLE_CONST_HEIGHT(50),
};

LV_STYLE_CONST_INIT(style1, style1_props);

lv_obj_add_style(btn, &style1, 0);

+1 on this one.

It looks like the ability to use const styles got lost in the transition from lv_obj_set_style to lv_obj_add_style.

Is this something that got lost or is this a deprecated functionality?

Having the same issue here on LVGL 9.2.2. Everything works once I remove the const from the const keyword from lv_style_const_prop_t

Working fine enough for now, but it doesn’t look like RAM is actually being saved using this method because I tried defining the style normally within my display and that ended up saving a bit of RAM over using lv_style_const_prop_t


579540 bytes FLASH
102703 bytes RAM

VS


579468 bytes FLASH
102660 bytes RAM

So just defining the style normally would save 43 bytes of RAM. I’m having issues when defining the style normally as a global variable, so I can’t run a more accurate test until I get that resolved.
Still definitely better to use this in the long run since I’ll have multiple display functions using this label style, but individually, it doesn’t look like it’s working that way