Controls the recognition of possible unintentional logical errors.
#pragma warn_possunwant on | off | reset
If you enable this pragma, the compiler checks for common, unintended logical errors:
if (a=b) f(); /* WARNING: a=b is an assignment. */ if ((a=b)!=0) f(); /* OK: (a=b)!=0 is a comparison. */ if (a==b) f(); /* OK: (a==b) is a comparison. */
a == 0; // WARNING: This is a comparison. a = 0; // OK: This is an assignment, no warning
For example, The following listing generates a warning message.
i = sockcount(); while (--i); /* WARNING: empty loop. */ matchsock(i);
If you intended to create an infinite loop, put white space or a comment between the while statement and the semicolon. The statements in the following suppress the above error or warning messages.
while (i++) ; /* OK: White space separation. */ while (i++) /* OK: Comment separation */ ;