warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]

该警告希望你在&(逻辑与)表达式左右加上括号。有的时候&&(逻辑且)少写了一个&,也会产生该警告。

例如:   if((a[2]>>1)&0x1 == 1){ 

             .........

          }
应该将 (a[2]>>1)&0x1 用()号括起来。因为&运算符的优先级较低,低于==和!=运算符。


相关文章:

  • 2021-11-12
  • 2021-07-01
  • 2021-05-22
  • 2021-10-15
  • 2022-01-30
  • 2021-07-30
  • 2021-09-07
  • 2021-10-08
猜你喜欢
  • 2021-11-24
  • 2021-08-09
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2021-08-20
相关资源
相似解决方案