Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: eckard_klotz on October 12, 2016, 09:29:35 am

Title: How to activate cpp compiler-options for cpp-sources only and not for all
Post by: eckard_klotz on October 12, 2016, 09:29:35 am
Hello Everybody.

Currently I'm working on a C++ project that is using some third-party C files also. I have configured the Code::Blocks project (compiler-options) to use C++ 11.

Now I get the following warning message:
Code
||warning: command line option '-std=c++11' is valid for C++/ObjC++ but not for C|

Actually the content of the message is understandable. Furthermore the build-result is working, thus you may tell me just to ignore this warning or you may may suggest to deactivate this warning. But my experience is that it is the better solution to solve the root-cause of a warning to prevent future problems. 

Is it possible some how to configure for a single project and for a special kind of file (in my case cpp only) to use additional compiler-options only to avoid that other files will be compiled with this option ?

I'm using the 25th September 2016 build (10912) of Code::Blocks on Windows 7 with MinGW TDM-GCC 4.9. 

Best regards,
                      Eckard.



Title: Re: How to activate cpp compiler-options for cpp-sources only and not for all
Post by: stahta01 on October 12, 2016, 03:24:28 pm
If I remember right, you need to right click on the flags and then a menu is displayed.

Tim S.
Title: Re: How to activate cpp compiler-options for cpp-sources only and not for all
Post by: eckard_klotz on October 12, 2016, 05:02:57 pm
Hello Tim S.

Thanks for the tip.

If I list the C++ only Flags after right-clicking I see:
Quote
-std=c++98 -std=c++03 -std=gnu++98 -std=gnu++03 -std=c++11 -std=c++0x -std=gnu++11 -std=gnu++0x -std=c++1y -std=gnu++1y -static-libstdc++ -shared-libstdc++ -fpermissive -fdeduce-init-list -fcheck-new -fstrict-enums -Weffc++ -Wctor-dtor-privacy -Wdelete-non-virtual-dtor -Wliteral-suffix -Wc++11-compat -Wnoexcept -Wnon-virtual-dtor -Wreorder -Wstrict-null-sentinel -Wno-non-template-friend -Wnon-template-friend -Wold-style-cast -Woverloaded-virtual -Wno-pmf-conversions -Wsign-promo

If I list the C only Flags after right-clicking I see:
Quote
-std=c90 -std=c89 -std=iso9899:1990 -std=iso9899:199409 -std=c99 -std=c9x -std=iso9899:1999 -std=iso9899:199x -std=c11 -std=c1x -std=iso9899:2011 -std=gnu90 -std=gnu89 -std=gnu99 -std=gnu9x -std=gnu11 -std=gnu1x

Until now I have changed nothing by using this context-menu options and this are the original settings delivered with Code::Blocks. If the flags listed as "C++ only Flags" will only be used while the C++ compilation why do I get the warning?

This is a reduced build log of a single c-source where the flag -std=c++11 is used even it is c++ only :
Quote
mingw32-gcc.exe -DRT -DWINDOWS_DLL -O2 -Wall -std=c++11 -DBUILD_DLL -DRT -DNUMST=2 -DNCSTATES=0 -I[Root]\R2010bSP1 -I[Root]\R2009b -I[Root]\R2007b -I[Root]\R2011b -I[Root]\cpp -I[Root]\h  -c [Root]\c\rt_look.c -o obj\Release\[Root]\c\rt_look.o
cc1.exe: warning: command line option '-std=c++11' is valid for C++/ObjC++ but not for C

Could this be a bug?

Best regards,
                       Eckard.
Title: Re: How to activate cpp compiler-options for cpp-sources only and not for all
Post by: oBFusCATed on October 12, 2016, 09:24:00 pm
Probably it is a bug...