简体   繁体   English

cc1plus:对任何其他警告的无法识别的命令行选项警告

[英]cc1plus: unrecognized command line option warning on any other warning

I have a strange behavior of g++ that it shows a warning about unrecognized command line option, when any other warning is shown. 我有一个奇怪的g ++行为,当显示任何其他警告时,它会显示有关无法识别的命令行选项的警告。

Example: 例:

struct Foo{virtual int bar() = 0;};
struct Bar:public Foo{int bar() {return 0;} };

int main(){}

Compiling with g++-5 -Wsuggest-override -Wno-c99-extensions -std=c++11 a.cpp or even g++-5 -Wsuggest-override -Wno-c99-extensions a.cpp shows: g++-5 -Wsuggest-override -Wno-c99-extensions -std=c++11 a.cpp编译g++-5 -Wsuggest-override -Wno-c99-extensions -std=c++11 a.cpp甚至g++-5 -Wsuggest-override -Wno-c99-extensions a.cpp显示:

a.cpp:2:27: warning: ‘virtual int Bar::bar()’ can be marked override [-Wsuggest-override]
 struct Bar:public Foo{int bar() {return 0;} };
                           ^
cc1plus: warning: unrecognized command line option ‘-Wno-c99-extensions’

ADDITION: There is no warning/error when I compile with g++-5 -Wno-c99-extensions a.cpp hence that option passes CMAKEs check using CHECK_CXX_COMPILER_FLAG 附加:使用g++-5 -Wno-c99-extensions a.cpp编译时没有警告/错误因此该选项使用CHECK_CXX_COMPILER_FLAG检查CMAKEs检查

This bothers me quite a lot, as we use Werror but with exceptions via Wno-error=... It then bails out when any of the (non-error) warnings is shown with the "unrecognized command line option" 这让我很烦恼,因为我们使用Werror但是有例外,通过Wno-error = ...当任何(非错误)警告显示“无法识别的命令行选项”时,它会失效

Is this known/expected? 这是已知/预期的吗? How can it be prevented? 如何预防?

If you don't want warnings about unrecognised command-line options, don't use unrecognised command-line options: -Wno-c99-extensions has never been a valid GCC option (I believe it's a clangism). 如果您不希望发出有关无法识别的命令行选项的警告,请不要使用无法识别的命令行选项: -Wno-c99-extensions从未成为有效的GCC选项(我相信这是一种讽刺)。 Simply remove it from your build command. 只需从构建命令中删除它。

As for why the warning is only emitted when you have another warning present, this behaviour seems counter-intuitive but it is actually deliberate and documented : 至于为什么只有当你有另一个警告时才会发出警告,这种行为似乎违反直觉的,但它实际上是经过深思熟虑和记录的

The warning "unrecognized command-line option" is not given for -Wno-foo -Wno-foo没有给出警告“无法识别的命令行选项”

Since GCC 4.4, and as explained in the GCC manual: when an unrecognized warning option is requested ( -Wunknown-warning ), GCC emits a diagnostic stating that the option is not recognized. 自GCC 4.4以来,如GCC手册中所述: 当请求无法识别的警告选项时( -Wunknown-warning ),GCC会发出一个诊断,指出该选项无法识别。 However, if the -Wno- form is used, the behavior is slightly different: no diagnostic is produced for -Wno-unknown-warning unless other diagnostics are being produced. 但是,如果使用-Wno-形式,则行为略有不同:除非正在生成其他诊断,否则不会为-Wno-unknown-warning生成诊断。 This allows the use of new -Wno- options with old compilers, but if something goes wrong, the compiler warns that an unrecognized option is present. 这允许在旧编译器中使用新的-Wno-选项,但是如果出现问题,编译器会警告存在无法识别的选项。 (See PR28322 for the history of this change) (有关此更改的历史,请参阅PR28322)

This might break configure tests that check for -Wno-foo options. 这可能会破坏检查-Wno-foo选项的配置测试。 The solution is to either test for the positive form ( -Wfoo ) or test using a testcase that triggers some other warning. 解决方案是测试正形式( -Wfoo )或使用触发其他警告的测试用例进行测试。

There are in fact a few results on Google of mailing list threads where software developers have faced this "problem", specifically with CMake, and made trivial fixes to their build scripts to "fix" it. 实际上谷歌的邮件列表线程中有一些结果,软件开发人员已经面临这个“问题”,特别是CMake,并对他们的构建脚本做了一些简单的修复以“修复”它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么“cc1plus:警告:无法识别的命令行选项”用于“no-”选项仅在有另一个警告时由g ++标记? - why is “cc1plus: warning: unrecognized command line option” for “no-” options only flagged by g++ when there is another warning? cc1plus:警告:命令行选项“ -Wstrict-prototypes”对Ada / C / ObjC有效,但对C ++无效 - cc1plus: warning: command line option “-Wstrict-prototypes” is valid for Ada/C/ObjC but not for C++ 无法解析cc1plus:错误:无法识别的命令行选项“ -std = c ++ 11” - Failed to resolve cc1plus: error: unrecognized command line option “-std=c++11” cc1plus:错误:无法识别的命令行选项“-std=c++0x” - cc1plus: error: unrecognized command line option "-std=c++0x" cc1plus:错误:hxcpp无法识别的命令行选项“ -stdlib = libstdc ++” - cc1plus: error: unrecognized command line option “-stdlib=libstdc++” with hxcpp cc1plus:错误:无法识别的命令行选项“ -Wno-implicit-fallthrough” [-Werror] - cc1plus: error: unrecognized command line option “-Wno-implicit-fallthrough” [-Werror] cc1plus:错误:无法识别的命令行选项“ -fsysroot = <path> ”和g ++ - cc1plus: error: unrecognized command line option “-fsysroot=<path>” with g++ cc1plus:错误:无法识别的命令行选项“ -std = gnu ++ 11” - cc1plus: error: unrecognized command line option “-std=gnu++11” 为什么我得到cc1plus:错误:无法识别的命令行选项“-arch”? - Why do I get cc1plus: error: unrecognized command line option “-arch”? cc1plus:错误:使用g ++无法识别的命令行选项“-std = c ++ 11” - cc1plus: error: unrecognized command line option “-std=c++11” with g++
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM