Invalid conversion in ui_theme_manager.cpp

What do you want to achieve?

compile project after update to SLS 1.4.0 and adding theme.

getting two compile errors of similar type: some invalid conversion related to lv_mem_realloc()

Thanks a lot for your advice.

compiler errors ui_theme_manager.cpp:98:38

src/src/Display/GUI/ui_theme_manager.cpp: In function ‘_ui_local_style_t* _ui_local_style_create(const ui_style_variable_t*, bool)’:

src/src/Display/GUIui_theme_manager.cpp:98:38: error: invalid conversion from ‘void*’ to ‘_ui_local_style_t*’ [-fpermissive]

_ui_local_styles = lv_mem_realloc( _ui_local_styles, (_ui_local_style_count + 1) * sizeof(_ui_local_style_t) );

compiler errors ui_theme_manager.cpp:139:65:

src/src/Display/GUI/ui_theme_manager.cpp: In function ‘_ui_local_style_property_setting_t* _ui_local_style_property_setting_create(_ui_local_style_t*, lv_obj_t*, lv_style_selector_t, lv_style_prop_t)’:

src/src/Display/GUI/ui_theme_manager.cpp:139:65: error: invalid conversion from ‘void*’ to ‘_ui_local_style_property_setting_t*’ [-fpermissive]
local_style_p->style_property_settings = lv_mem_realloc (
(local_style_p->style_property_setting_count + 1) * sizeof(_ui_local_style_property_setting_t)


  • SquareLine Studio version:
  • Operating system:
  • Target hardware:
    custom esp32-s3

The problem: C compiler likes to have the memory-allocations as void*, but in your case the C++ compiler doesn’t only throw a warning, but stops with an error if there aren’t castings before memory allocations. We’ll take care of this for C++ exports, but for now you can find several easy solutions to circumvent this in this duplicate topic: 1.4: memory allocation bug with styles
Probably the best option is to set ‘-fpermissive’ in your compiler options, so it will only give a warning and compile fine.