1、现象
2、原因
这个编译器报错信息 error: bitwise comparison always evaluates to false [-Werror=tautological-compare] 表示在你的代码中存在一个按位运算的比较,它在所有情况下都会评估为 false。这是因为这种比较的结果在逻辑上是不可能为 true 的,通常是由于编程错误或逻辑问题导致的。
3、解决方案
(1)检查比较逻辑:重新检查代码中的逻辑,确保位操作的使用是合理的,并且比较的条件是可能为 true 的。
(2)调整掩码或比较条件:如果是掩码问题,调整掩码或比较的值,使得条件在特定情况下可以为 true。
(3)抑制警告(非推荐):如果你确定代码逻辑没有问题,且希望忽略此类警告,可以通过 -Wno-tautological-compare 编译选项来抑制这个警告。不过,这种做法一般不推荐,因为它可能掩盖了代码中的潜在错误。
这里采用忽略警告的方式,在makefile文件中编译选项加上-Wno-tautological-compare
重新编译没有报错: