Disable warning errors

I am using an external component with espidf and it seems that there are a few GCC -Werror= flags (e.g. -Werror=unused-const-variable and -Werror=format-truncation) that prevents it from building:

components/lcd/Adafruit-GFX-Library/glcdfont.c:18:28: error: 'font' defined but not used [-Werror=unused-const-variable=]
components/lcd/iot_lcd.cpp:511:36: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=]

How can I disable these flags? I tried stuff like setting build_unflags in platformio.ini without success so far:

build_unflags = -Werror=unused-const-variable

I was also unable to locate where these flags were configured in the first place.

Thanks for your help.

Maybe try a Wno-error=unused-const-variable in the build_flags.

Probably in the depths of ESP-IDFs CMake scripts.

However you should try and get a view at the used GCC flags first by running pio run -v for a “Verbose Build”, and see if there really are -Werror=.. flags or if its activated else how.

1 Like

Thanks. I used pio run -v and found that GCC used -Werror=all flag (which is a surprising default I think).

Anyways, this is fixed using build_unflags = -Werror=all.

2 Likes