C++ 如何禁用缩小转换警告?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20302595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable narrowing conversion warnings?
提问by klm123
I use -Wall
and updating to new gcc I have got a lot of warning: narrowing conversion
. I want to disable them, but leave all other warnings untouched (ideally).
我使用-Wall
并更新到新的 gcc 我有很多warning: narrowing conversion
. 我想禁用它们,但保持所有其他警告不变(理想情况下)。
I can find nothing about narrowing
in http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
我narrowing
在http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html 中找不到任何相关信息
How to disable narrowing conversion warnings? Is it possible at all?
如何禁用缩小转换警告?有可能吗?
P.S.
聚苯乙烯
I need to Disable warnings, not fix them in the source code.
Blind
-Wno-conversion
doesn't help.
我需要禁用警告,而不是在源代码中修复它们。
盲
-Wno-conversion
也没用。
回答by Stryck
As gx_ said, adding -Wno-narrowing
to your command line should ignore those errors. Encountered this myself when upgrading to C++0x.
正如 gx_ 所说,添加-Wno-narrowing
到命令行应该忽略这些错误。升级到 C++0x 时自己遇到了这个问题。
回答by Ben
As a small FYI, as detailed on https://clang.llvm.org/docs/DiagnosticsReference.html#wnarrowingthis is an alias for -Wno-c++11-narrowing (there are multiple narrowing warning flags)
作为一个小的仅供参考,如https://clang.llvm.org/docs/DiagnosticsReference.html#wnarrowing 所述,这是 -Wno-c++11-narrowing 的别名(有多个缩小警告标志)