我正在将我在 CodeWarrior v5.2 中开发的应用程序迁移到使用 ARM C 编译器 v5.06 的 Keil uVision v5.25。
在我的代码中,我用来bool
表示布尔值,它types.h
在我的项目的文件中定义为:
typedef enum _bool
{
false = 0,
true = 1
} bool;
当我尝试编译我的代码时,编译器会生成有关我将比较结果隐式分配给具有这种类型的变量的行的警告:
src\c\drivers\motor.c(168): warning: #188-D: enumerated type mixed with another type
const bool motorStopped = timeSinceLastEvent > maxPulseWidth;
src\c\drivers\motor.c(169): warning: #188-D: enumerated type mixed with another type
const bool motorStalled = motorStopped && isMotorDriven();
我理解为什么会产生这些警告。我知道我可以通过显式转换为来抑制这些警告bool
,例如:
const bool motorStopped = (bool)(timeSinceLastEvent > maxPulseWidth);
但是,对每个布尔条件都这样做是非常难看的。我想知道是否有一种方法可以将 Keil uVision / ARM 编译器(或修改我的代码)配置为不生成关于 的警告bool
,而不会完全禁用有关将枚举类型与其他类型混合的警告。
这些是我可用于配置编译器的选项: