C++ 如何忽略“有符号和无符号整数表达式之间的比较”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4377948/
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-28 15:16:08  来源:igfitidea点击:

How to ignore 'comparison between signed and unsigned integer expressions'?

c++gcc

提问by Andrei

Can anybody please tell me which flag I have to use in order to make gcc ignore the 'comparison between signed and unsigned integer expressions' warning message.

任何人都可以告诉我我必须使用哪个标志才能使 gcc 忽略“有符号和无符号整数表达式之间的比较”警告消息。

回答by robert

gcc -Wno-sign-compare

gcc -Wno-sign-compare

But you should really fix the comparison it's warning you about anyway.

但是你真的应该修复它警告你的比较。

回答by the_architect

Here's what worked for me, using the gcc compiler in Code::Blocks. In the compiler settings, click the "Compiler Settings" tab, then choose "Other Compiler Options. Type in -Wno-sign-compareThe warning -Wsign-comparecan be negated by adding "-Wno" as a prefix. In fact warnings can be ignored by adding -Wno-to the warning code.

这是对我有用的方法,在 Code::Blocks 中使用 gcc 编译器。在编译器设置中,点击“Compiler Settings”选项卡,然后选择“Other Compiler Options。输入 -Wno-sign-compare警告-Wsign-compare可以通过添加“-Wno”作为前缀来否定。实际上是警告可以通过在警告代码中添加-Wno-来忽略。