Is it possible in C++ to define BIT0, BIT1, BIT2 in another way in C++ without using #define?
#define BIT0 0x00000001
#define BIT1 0x00000002
#define BIT2 0x00000004
I then take the same thing and make states out of those bits:
#define MOTOR_UP BIT0
#define MOTOR_DOWN BIT1
Note: I am using 32 bits only, not 64 bits. I am also using a setBit(flagVariable, BIT)
(consequently a clrBit
macro to do the opposite) macro to set the bits then compare whether the bit is set using the bitwise operator such as
if (flagVariable & MOTOR_UP) {
// do something
clrBit(flagVariable, MOTOR_UP);
}
Is there a type in C++ that already contains these bit masks?