简体   繁体   中英

Visual Studio C vs. C++ Flag Issue

In Visual Studio, have things setup (using vs-android) to apply -std=c++11 through the "Additional Options" in "Compiler Arguments" in the project. Which is good, because it applies it to all compiled files.

Except when it tries to compile a C file:

cc1.exe : warning : command line option '-std=c++11' is valid for C++/ObjC++ but not for C [enabled by default]

Which is just a warning, but it slows down the build ever so slightly every time, and there's a lot of pure C files.

Is there any way to make an exception for this in Visual Studio, so it isn't done to C files, but only C++ files?

Alas, there's no way to do it in the manner you are looking for.

One thing that may work for you, depending on if you are using any other global command-line options or not, is select all of your .C files in the project, and in the compiler options un-check the "Inherit from parent or project defaults" checkbox just above the Additional Options box. You should be able to do it for all of your C files in one shot by ctrl-selecting them and then right-click/Properties/etc. Then any of the extra command-line options you set at the project level will not be used for those files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM