Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
317 - Incorrect operator.
Additional Information: Logical-not (!) is not interchangeable with ones-complement (~).
This message indicates that PREfast detected logical-NOT (!) being applied to a constant likely to be a bit-flag.
The result of logical-NOT is Boolean. It is incorrect to apply the bitwise-AND (&) operator to a Boolean value.
Use the ones-complement (~) operator to flip flags.
Example
Defective Source
#define FLAGS 0x4004
if (a & !FLAGS) {;}
Corrected Source
#define FLAGS 0x4004
if (a & ~FLAGS) {;}
Send Feedback on this topic to the authors