我遇到了几天的问题。
我在编译我的程序时收到此警告。
In member function 'void CClientManager::RESULT_SAFEBOX_LOAD(CPeer*, SQLMsg*)':
661:25: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
if (!dwSkillVnum > 120)
^
还有一个警告:
661:25: warning: comparison of constant '120' with boolean expression is always false [-Wbool-compare]
我想提一下,这两个警告是在我上g++5.1.0之后出现的 在我使用 g++4.2 之前,我有这个警告。 那么我该如何解决这个问题。
这是我的文件:http://pastebin.com/fWYYmXsH
最佳答案
operator!()
的优先级高于 operator>()
,因此您可以有效地将 !dwSkillVnum
转换为 bool
并将其与整数值进行比较。
要按照警告中的说明正确放置括号:
if (!(dwSkillVnum > 120))
// ^ ^
关于c++ - 警告 : Wlogical-not-parentheses,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30556317/