31-01-2006, 10:12 PM
The example only shows relational operators { < >= }.
What about other operators?
#define OPTION_ONE 0x01
#define OPTION_TWO 0x02
#define MY_OPTIONS (OPTION_ONE)
- or -
#define MY_OPTIONS (OPTION_TWO)
- or -
#define MY_OPTIONS (0x00)
- or -
#define MY_OPTIONS (OPTION_ONE | OPTION_TWO)
if ((MY_OPTIONS & OPTION_ONE) != 0) /* deviation from 13.7? */
{
...
}
In this case, equality operators { == != } are less likely to \"accidentally\" be always true/false (vs. intentionally always true/false), while relational operators can sometimes catch the programmer of guard (due to limited ranges of smaller integer types: [-128 to +127], [0 to +255], etc.
What about sub-expressions?
if ((u8
What about other operators?
#define OPTION_ONE 0x01
#define OPTION_TWO 0x02
#define MY_OPTIONS (OPTION_ONE)
- or -
#define MY_OPTIONS (OPTION_TWO)
- or -
#define MY_OPTIONS (0x00)
- or -
#define MY_OPTIONS (OPTION_ONE | OPTION_TWO)
if ((MY_OPTIONS & OPTION_ONE) != 0) /* deviation from 13.7? */
{
...
}
In this case, equality operators { == != } are less likely to \"accidentally\" be always true/false (vs. intentionally always true/false), while relational operators can sometimes catch the programmer of guard (due to limited ranges of smaller integer types: [-128 to +127], [0 to +255], etc.
What about sub-expressions?
if ((u8