ESP32 Compilation Warnings

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.
Post Reply
mnfisher
Valued Contributor
Posts: 1217
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 118 times
Been thanked: 626 times

ESP32 Compilation Warnings

Post 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....

BenR
Matrix Staff
Posts: 1899
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 491 times
Been thanked: 665 times

Re: ESP32 Compilation Warnings

Post 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!

mnfisher
Valued Contributor
Posts: 1217
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 118 times
Been thanked: 626 times

Re: ESP32 Compilation Warnings

Post 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

BenR
Matrix Staff
Posts: 1899
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 491 times
Been thanked: 665 times

Re: ESP32 Compilation Warnings

Post 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.

mnfisher
Valued Contributor
Posts: 1217
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 118 times
Been thanked: 626 times

Re: ESP32 Compilation Warnings

Post by mnfisher »

It's good isn't it :-)

Especially with EEZ (or SquareLine) Studio

Martin

Post Reply