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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 23:02:01  来源:igfitidea点击:

How to disable narrowing conversion warnings?

c++gccwarningsgcc4.7compiler-options

提问by klm123

I use -Walland 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 narrowingin http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

narrowinghttp://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html 中找不到任何相关信息

How to disable narrowing conversion warnings? Is it possible at all?

如何禁用缩小转换警告?有可能吗?

P.S.

聚苯乙烯

  1. I need to Disable warnings, not fix them in the source code.

  2. Blind -Wno-conversiondoesn't help.

  1. 我需要禁用警告,而不是在源代码中修复它们。

  2. -Wno-conversion也没用。

回答by Stryck

As gx_ said, adding -Wno-narrowingto 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 的别名(有多个缩小警告标志)