Timer example not compiling


Trying to compile the Timer example.
But compilation fails (Use the user_data) with: a value of type "void *" cannot be used to initialize an entity of type "uint32_t *"

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

ESP32 with Arduino environment (c++)

What LVGL version are you using?


What do you want to achieve?

Compiling to succeed, and to understand why it doesn’t compile.

Code to reproduce

void my_timer(lv_timer_t * timer)
  /*Use the user_data*/
  uint32_t * user_data = timer->user_data;
  printf("my_timer called with user data: %d\n", *user_data);

  /*Do something with LVGL*/
  if(something_happened) {
    something_happened = false;
    lv_btn_create(lv_scr_act(), NULL);


static uint32_t user_data = 10;
lv_timer_t * timer = lv_timer_create(my_timer, 500,  &user_data);

Hi, timer->user_data is a void pointer. So if you replace the line with :

uint32_t * user_data = reinterpret_cast<uint32_t*>(timer->user_data);

it should work.

Thank you!