C语言中运算符的优先级问题
今天在写代码的过程中,发现了一个自己平时没有过多注意的问题。gcc
给下面的语句出了一句警告。报错的原因非常简单:按位与运算符(&
)的优先级要比等号运算符(==
)的优先级低。
if (size() & 1 == 0) {
// ...
}
"message": "suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]"`
今天在写代码的过程中,发现了一个自己平时没有过多注意的问题。gcc
给下面的语句出了一句警告。报错的原因非常简单:按位与运算符(&
)的优先级要比等号运算符(==
)的优先级低。
if (size() & 1 == 0) {
// ...
}
"message": "suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]"`