I would check if my code is fine w.r.t.
-Wall -Wextra -Wpedantic. However, the underlying libraries and framework throw a huge amount of warnings, so that finding the output for my sources is almost impossible.
Is there a way to compile only my source code in PlatformIO? I think I don’t need to link to framework for these checks.
framework = .. line in the
platformio.ini removes the link to the framework (e.g. Arduino core) and only builds the sources in
lib/. If there’s a reference to any framework file, it will fail of course.
On the other hand, per Advanced Scripting can be used to inject arbitrary compiler flags on a few selective sources. You could e.g. try a simple script like e.g.
Import("projenv") # projenv is used for only sources in the project folder projenv.Append(CCFLAGS=["-Wall", "-Wextra", "-Wpedantic"])
extra_scripts = pedantic_checks.py
platformio.ini, and verify that with the project task “Advanced → Verbose Build”. Not tested.
projenv.Append(CCFLAGS=["-Wall", "-Wextra", "-Wpedantic"]) be applied to
src folders of my project directory?
Per linked documentation about
projenv, no, only
In the case of modifying build flags for libs however one can take a very general approach as in Granular optimisation settings to modify the flags arbitrary for any file (that can then be further filtered by filename or path etc.)
projenv.Append(CCFLAGS=["-Wall", "-Wextra", "-Wpedantic"]) very similar to
Good catch, I wasn’t aware of that. But per docs yes. So that makes above redudant.
many thanks! However there is another problem (already seen in this forum): system/framework headers contains many warnings.
I read this “old” topic, but it seems a solution (last post) is
#pragma GCC diagnostic, which is not very appealing since I have to modify all the files in my library (I will do if it is THE solution):
Maybe new solutions are emerged in the meanwhile…