다음을 통해 공유


PREfast Warning 317 (Windows CE 5.0)

Send Feedback

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

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.