Compilation error with LV_LABEL_TEXT_SEL = 0 in Dev 6.1

Description

Compilation error with undefined return value in Dev 6.1

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

Keil uVision MDK 5.27 with ARMCC V5.06 update 6 toolchain.

What do you experience?

Build fails with undefined identifier for LV_LABEL_TEXT_SEL_OFF.

compiling lv_label.c...
..\..\lvgl\src\lv_objx\lv_label.c(730): error:  #20: identifier "LV_LABEL_TEXT_SEL_OFF" is undefined
      return LV_LABEL_TEXT_SEL_OFF;
..\..\lvgl\src\lv_objx\lv_label.c(748): error:  #20: identifier "LV_LABEL_TEXT_SEL_OFF" is undefined
      return LV_LABEL_TEXT_SEL_OFF;
..\..\lvgl\src\lv_objx\lv_label.c: 0 warnings, 2 errors

Two functions:

uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label)

Both return LV_LABEL_TEXT_SEL_OFF when LV_LABEL_TEXT_SEL = 0

#if LV_LABEL_TEXT_SEL
.
.
.
#else
    (void)label;    /*Unused*/
    return LV_LABEL_TEXT_SEL_OFF;
#endif

What do you expect?

Definition of LV_LABEL_TEXT_SEL_OFF should be in lv_label.h

#define LV_LABEL_TEXT_SEL_OFF 0xFFFF

Code to reproduce

Define text select to 0 and build.

#define LV_LABEL_TEXT_SEL    0

I fixed this in my local copy of LittlevGL but I haven’t pushed it to GitHub yet. I will try and do that as soon as possible.

I would think that defining LV_LABEL_TEXT_SEL_OFF to 0 makes more sense; the value you suggested doesn’t fit in a uint16_t (and having no selection support would be equivalent to having nothing selected).

Sorry, the value I had in my original post was a typo. I have edited it to be 0xFFFF. You are probably right that 0x0 would be more appropriate. I chose 0xFFFF because I found that was what is set at one point in master.

I wonder why it disappeared. I’ll have a look at git log.

I changed the API of lv_draw_label to solve some warnings and changed this define to LV_DRAW_LABEL_NO_TXT_SEL. I’ve forgotten that it might affect public things.

I’ve added LV_LABEL_TEXT_SEL_OFF again.