Unused Variable 'target' Warning when Compiling

What do you want to achieve?

My ui.c contains lv_obj_t * target = lv_event_get_target(e); in 147 places which is not used for anything. This generates warning: unused variable 'target' [-Wunused-variable] 147 times since it is not used.

Why is this line of code being generated if it is not used?

Screenshot or video

Here is one example:


  • **SquareLine Studio version: 1.3.1
  • **Operating system: Windows 10 x64
  • **Target hardware: ESP32-S3, ESP-IDF 5.1, LVGL 8.3.6

Just a +1, this exists for me as well. Warnings like this cause lots of noise in the build log.

Thanks for the report, we added it to our todo list.

Just bumping as these warnings still exist in SDS 1.3.3.

We have already started working on eliminating warnings during export. It is expected that they will be resolved in the next release.

1 Like

c:\Users\aimst\Desktop\shree_ganesha\SquareLine_Project\libraries\ui\src\ui_events.c: In function ‘fan_speed_value’:
c:\Users\aimst\Desktop\shree_ganesha\SquareLine_Project\libraries\ui\src\ui_events.c:11:16: error: unused variable ‘target’ [-Werror=unused-variable]
lv_obj_t * target = lv_event_get_target(e);
cc1.exe: some warnings being treated as errors
c:\Users\aimst\Desktop\shree_ganesha\SquareLine_Project\libraries\ui\src\ui.c: In function ‘ui_event_Slider1’:
c:\Users\aimst\Desktop\shree_ganesha\SquareLine_Project\libraries\ui\src\ui.c:36:16: error: unused variable ‘target’ [-Werror=unused-variable]
lv_obj_t * target = lv_event_get_target(e);

Your toolchain seems to be picky about unused variables, in most tools this only throws a warning by default and compiles the project fine.
You can modify this behaviour by using -Wno-unused-variable argument with your compiler.