如何禁用GCC警告" CC1:警告:命令行选项'-std = C ++ 11'是有效的C ++ / ObjC ++而不是C [默认启用] QUOT; [英] how to disable gcc warning "cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C [enabled by default]"
问题描述
我是新来的CMake和gcc。
我在公司的新角色的第一个任务是清理我们的Linux编译错误
我做了大部分,现在我看到的唯一警告
I am new to cmake and gcc. The first assignment in my new role in the company was to clean the errors from our linux compilation I did most of it, and now the only warning I see is
CC1:警告:命令行选项'-std = C + + 11的有效期为C ++ / ObjC ++而不是C [默认启用]
我要枯萎燮preSS警告或解决问题的cmake的文件。
不幸的是,我还没有找到适合这里的正确 -Wno-XXX
语句。
I want wither to suppress the warning or to solve the issue in the cmake file.
Unfortunately, I still haven't found the correct -Wno-xxx
statement that fits here.
谢谢!
推荐答案
code发出警告可与沉默 -Wno-XXX
选项,因为有时你不吨有超过源$ C $ C控制。但是,一个警告信息,告诉你一个的命令行选项的不正确,不能用另一个命令行选项沉默 - 如果你能影响编译器调用,那么为什么不直接删除不正确的选项。
Code issue warnings can be silenced with -Wno-xxx
options because sometimes you don't have control over the source code. But a warning telling you that a command-line option is incorrect cannot be silenced with yet another command-line option — if you can affect compiler invocation, then why not just remove the incorrect option?
这特别的警告,告诉您编译C code时,你可以不设置标准C ++ 11。为了摆脱它,发现其中 -std = C ++ 11
在生成配置定义,并确保它仅适用于C ++编译,并没有对C例如,从 CFLAGS
移至 CXXFLAGS
,或CMake的的等同物。
This particular warning tells you that you cannot set standard to C++11 when compiling C code. To get rid of it, find where -std=c++11
is defined in the build configuration, and make sure it is only applied to C++ compilation, and not for C. For example, move it from CFLAGS
to CXXFLAGS
, or cmake's equivalent thereof.
这篇关于如何禁用GCC警告" CC1:警告:命令行选项'-std = C ++ 11'是有效的C ++ / ObjC ++而不是C [默认启用] QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!