Page 1 of 1

ESP32 Compilation Warnings

Posted: Sat Apr 27, 2024 9:10 pm
by mnfisher
A little tip to make life easier.

The output from the esp32 compiler is a 'little' verbose. It is possible to turn off some of the warnings.

In your project directory/main

Edit CMakeLists.txt

At the end of the file add:

Code: Select all

target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-unused-variable)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-unused-function)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-int-conversion)
This will turn off unused variable and function warnings as well as conversion between integer types. Obviously you should aim to tidy up the code that gives these messages - but it makes spotting the error 'needle' easier in the early project haystack...

Martin

Other warnings can be disabled using similar syntax....

Re: ESP32 Compilation Warnings

Posted: Wed Sep 04, 2024 2:57 pm
by BenR
Thanks Martin,

Just getting round to this and I've updated the default file so that the following applies when compiling a new project.

Code: Select all

target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-cpp)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-unused-function)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-unused-variable)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-unused-but-set-variable)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-incompatible-pointer-types)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-discarded-qualifiers)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-int-conversion)
I've also popped this line in there should you want to disable to treat certain warnings as errors, e.g. return variable not set or variable not initialised etc.

Code: Select all

#You can disable all warnings as errors by uncommenting the line below.
#target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-error)
Annoyingly I'd only seen your post once I'd found out and applied the info myself! doh!

Re: ESP32 Compilation Warnings

Posted: Wed Sep 04, 2024 4:25 pm
by mnfisher
Thanks Ben,

It makes for a much nicer working environment - I mentioned it again in the notes about lvgl - where there are reams of warnings...

Martin

Re: ESP32 Compilation Warnings

Posted: Wed Sep 04, 2024 4:57 pm
by BenR
I've got a copy of LVGL compiling now too so looking forward to having a play with it and seeing what we can do with it going forward.

Re: ESP32 Compilation Warnings

Posted: Thu Sep 05, 2024 9:43 am
by mnfisher
It's good isn't it :-)

Especially with EEZ (or SquareLine) Studio

Martin