Need to pass CXX_FLAGS to Framework build

The background: We have some code which uses c++17 features in the application based on the mbed framework. The mbed framework uses the register keyword, which is no longer supported in the C++17 standard. Thus g++ issues a lot of (harmless) warnings. To cut these warnings we can add -Wno-register to the build_flags.

For g++ this is fine. For gcc this results in a lot of

cc1.exe: warning: command line option ‘-Wno-register’ is valid for C++/ObjC++ but not for C

when compiling the mbed framework (or any other C (not C++) library code.
Using extra_scripts is not working, as it seems the CXX_FLAGS option set there are only passed to the application build but not to library builds.

Now the question: What is the way to pass a C++ specific compiler option to the framework or library builds? As explained extra_scripts using the env.Append( CXXFLAGS=[ “-Wno-register” ] ) is not the answer as it seems to work only for the application compiler options.

Probably you need to execute your extra script before the main build script, so could you try something like this:

[env:my_env_2]
platform = ...
extra_scripts =
  pre:extra_script.py
1 Like

Hi,
that did the trick!

Thank you!