Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Compiler Warning (level 4) C4706 (Windows CE 5.0)

Windows CE 5.0
Send Feedback

assignment within conditional expression

The test value in a conditional expression was the result of an assignment.

An assignment has a value (the value on the left side of the assignment) that can be used legally in another expression, including a test expression. The following code will generate this warning:

if ( a  = b )
{
...
}

The warning will occur even if you double the parentheses around the test condition:

if ( ( a  =  b ) )
{
...
}

If your intention is to test a relation and not to make an assignment, use the == operator. For example, the following line tests whether a and b are equal:

if ( a == b ) 
{
...
}

If you intend to make your test value the result of an assignment, test to ensure that the assignment is non-zero or not null. For example, the following code will not generate this warning:

if ( ( a = b ) != 0 ) 
{
...
}

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.


Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.