다음을 통해 공유


PREfast Warning 316 (Windows CE 5.0)

Send Feedback

316 - Incorrect operator.
Additional Information: Tested expression is constant and non-zero.
Recommended Fix: Use bitwise-and to determine whether bits are set.

This message indicates code where bitwise-OR (|) was used when bitwise-AND (&) should have been used.

Bitwise-OR adds bits to the resulting expression, but bitwise-AND selects only those bits in common between its two operators.

Tests for flags must be performed with bitwise-AND or a test of equality.

Example

Defective Source

if (Flags | 8)

Corrected Source

if (Flags & 8)

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.