I'm migrating an application I was developing in CodeWarrior v5.2 to Keil uVision v5.25, which uses the ARM C compiler v5.06.
Throughout my code I've used bool
to represent boolean values, which is defined in a types.h
file in my project as:
typedef enum _bool
{
false = 0,
true = 1
} bool;
When I try to compile my code, the compiler generates warnings about lines where I implicitly assign the outcome of comparisons to variables with this type:
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();
I understand why these warnings are being generated. I'm aware that I can suppress these warnings by explicitly casting to bool
, like:
const bool motorStopped = (bool)(timeSinceLastEvent > maxPulseWidth);
However, doing this for every boolean condition is pretty ugly. I was wondering if there's a way I can configure Keil uVision / the ARM compiler (or modify my code) to not generate warnings about bool
, without outright disabling warnings about mixing enumerated types with other types.
These are the options I have available to configure the compiler: