Lv_color.h:113:36: error: expected ';' before 'lv_color_t' (v8.1.0-dev)

Compiling the latest (v8.1.0-dev) LVGL with GCC for STM32 I get this only error:
lv_color.h:113:36: error: expected ';' before 'lv_color_t' (v8.1.0-dev)
Compiler uses -std=gnu17 switch. Adding parenthesis around lv_color_t fixes the problem but probably it is not the best solution.
Please advise.

Are you using it in a C or C++ file?

This is the second report I know of regarding this error.

(cc @kisvegabor)

I use gcc C compiler, the latest version, the latest standard gnu17, this is the exact command:
arm-none-eabi-gcc -std=gnu17 -c --specs=nano.specs -mfpu=fpv5-d16 -mcpu=cortex-m7 -mfloat-abi=hard -mthumb -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MFBUILD/debug/lvgl/src/misc/lv_color.o -MTBUILD/debug/lvgl/src/misc/lv_color.o -g -O0 -DUSE_HAL_DRIVER -DSTM32H7A3xx -DDEBUG -include lv_conf.h -include lv_demo_conf.h lvgl/src/misc/lv_color.c -o BUILD/debug/lvgl/src/misc/lv_color.o

ms-vscode.cpptools also detect some problem.

Ach, wait… my mistake.
Actually, the error occurs when I use C++ compiler.

repro.cpp

#include "lvgl/lvgl.h"
lv_color_t* color_p;

command:
arm-none-eabi-g++ -std=gnu++17 -c -fno-threadsafe-statics --specs=nano.specs -mfpu=fpv5-d16 -mcpu=cortex-m7 -mfloat-abi=hard -mthumb -ffunction-sections -fdata-sections -Wall -fstack-usage -fno-exceptions -fno-rtti -fno-use-cxa-atexit -MMD -MP -MFBUILD/debug/repro.o -MTBUILD/debug/repro.o -g -O0 -DDEBUG -include lv_conf.h repro.cpp -o BUILD/debug/repro.o

error:

$ arm-none-eabi-g++ -std=gnu++17 -c -fno-threadsafe-statics --specs=nano.specs -mfpu=fpv5-d16 -mcpu=cortex-m7 -mfloat-abi=hard -mthumb -ffunction-sections -fdata-sections -Wall -fstack-usage -fno-exceptions -fno-rtti -fno-use-cxa-atexit -MMD -MP -MFBUILD/debug/repro.o -MTBUILD/debug/repro.o -g -O0 -DDEBUG -include lv_conf.h repro.cpp -o BUILD/debug/repro.o
In file included from lvgl/src/hal/lv_hal_disp.h:21,
                 from lvgl/src/hal/lv_hal.h:16,
                 from lvgl/lvgl.h:30,
                 from repro.cpp:1:
lvgl/src/hal/../misc/lv_color.h: In function 'lv_color_t lv_color_make(uint8_t, uint8_t, uint8_t)':
lvgl/src/hal/../misc/lv_color.h:113:36: error: expected primary-expression before 'lv_color_t'
  113 | #define _LV_COLOR_MAKE_TYPE_HELPER lv_color_t
      |                                    ^~~~~~~~~~
lvgl/src/hal/../misc/lv_color.h:146:37: note: in expansion of macro '_LV_COLOR_MAKE_TYPE_HELPER'
  146 | # define LV_COLOR_MAKE8(r8, g8, b8) _LV_COLOR_MAKE_TYPE_HELPER  {{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}}
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
lvgl/src/misc/lv_types.h:77:26: note: in expansion of macro 'LV_COLOR_MAKE8'
   77 | #define _LV_CONCAT(x, y) x ## y
      |                          ^
lvgl/src/misc/lv_types.h:78:25: note: in expansion of macro '_LV_CONCAT'
   78 | #define LV_CONCAT(x, y) _LV_CONCAT(x, y)
      |                         ^~~~~~~~~~
lvgl/src/hal/../misc/lv_color.h:202:35: note: in expansion of macro 'LV_CONCAT'
  202 | #define LV_COLOR_MAKE(r8, g8, b8) LV_CONCAT(LV_COLOR_MAKE, LV_COLOR_DEPTH)(r8, g8, b8)
      |                                   ^~~~~~~~~
lvgl/src/hal/../misc/lv_color.h:604:39: note: in expansion of macro 'LV_COLOR_MAKE'
  604 |     return _LV_COLOR_MAKE_TYPE_HELPER LV_COLOR_MAKE(r, g, b);
      |                                       ^~~~~~~~~~~~~
lvgl/src/hal/../misc/lv_color.h:113:36: error: expected ';' before 'lv_color_t'
  113 | #define _LV_COLOR_MAKE_TYPE_HELPER lv_color_t
      |                                    ^~~~~~~~~~
lvgl/src/hal/../misc/lv_color.h:146:37: note: in expansion of macro '_LV_COLOR_MAKE_TYPE_HELPER'
  146 | # define LV_COLOR_MAKE8(r8, g8, b8) _LV_COLOR_MAKE_TYPE_HELPER  {{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}}
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
lvgl/src/misc/lv_types.h:77:26: note: in expansion of macro 'LV_COLOR_MAKE8'
   77 | #define _LV_CONCAT(x, y) x ## y
      |                          ^
lvgl/src/misc/lv_types.h:78:25: note: in expansion of macro '_LV_CONCAT'
   78 | #define LV_CONCAT(x, y) _LV_CONCAT(x, y)
      |                         ^~~~~~~~~~
lvgl/src/hal/../misc/lv_color.h:202:35: note: in expansion of macro 'LV_CONCAT'
  202 | #define LV_COLOR_MAKE(r8, g8, b8) LV_CONCAT(LV_COLOR_MAKE, LV_COLOR_DEPTH)(r8, g8, b8)
      |                                   ^~~~~~~~~
lvgl/src/hal/../misc/lv_color.h:604:39: note: in expansion of macro 'LV_COLOR_MAKE'
  604 |     return _LV_COLOR_MAKE_TYPE_HELPER LV_COLOR_MAKE(r, g, b);

Off-topic: while it makes perfect sense to globally force include lv_conf.h within LVGL project, it is probably not so great idea in projects where LVGL is a minor part of the complete code.
I suggest reconsidering the current approach in future versions.

I think I see the issue (it’s on our end)… are you using LV_COLOR_DEPTH == 8?

Correct!!!

Can you try this change?

It seems the fix helped. Thank you!

Great!

I’ve added an 8bpp configuration to our CI so we can catch this type of issue immediately. Thank you for making us aware of the fact that it was missing. :slightly_smiling_face: