How to create objects dynamically, is it possible?

Does anyone know how to create objects dynamically, is that possible? For example, a controller scanned some radio network and found number of sensors, how to create labels on a screen according to the number of sensors found?
I am using version 7.11 in simulator. Code example:
// Dynamic allocation of objects
lv_coord_t Y_POS = 40;
for (int i = 0; i < sen_num; i++) {
printf("%s\n", sensors[i].name);
lv_obj_t * lbl_sen[i] = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(lbl_sen[i], sensors[i].name);
lv_obj_add_style(lbl_sen[i], LV_BTN_PART_MAIN, &style_lbl_dt);
lv_obj_align(lbl_sen[i], NULL, LV_ALIGN_IN_TOP_LEFT, 20, Y_POS + 20);

It reports an error: “Expression must have a constant value” so it does not allow sen[i], any other way?

Your syntax for declaring the array of objects is incorrect.

I have changed declaration to:
lv_obj_t * lbl_sen[sen_num];
but still requires sen_num to have constant value in that expression.
It works when I put a number.

I think instead of array you can use simple lvgl object pointer

lv_obj_t * lbl_sen = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(lbl_sen, sensors[i].name);
lv_obj_add_style(lbl_sen, LV_BTN_PART_MAIN, &style_lbl_dt);
lv_obj_align(lbl_sen, NULL, LV_ALIGN_IN_TOP_LEFT, 20, Y_POS + 20);

Thanks glory-man. The simplest solution is always the best one.

Be careful with it. Every new object allocates memory in LVGL-memory-stack, and didn’t removed automaticaly

I thought that lv_obj_clean(lv_scr_act()) clean it when I move to the next screen.