'Possibly Incorrect Assignment' warnings from Turbo-C

Bob Stout Bob.Stout at p6.f506.n106.z1.fidonet.org
Mon Nov 27 09:51:26 AEST 1989


In an article of <24 Nov 89 18:07:29 GMT>, (Dave Hammond) writes:

 >In porting a program from Unix to Dos, I get an error from Turbo-C
 >`Possibly incorrect assignment' with code similar to the following:
 >
 >char *p, *func();
 >
 >if (p = func())
 >        do_something();

The warning (not an error) will go away if you use instead:

        if (0 != (p = func()))
                do_something();

The warning exists because it saw an assignment operator where it expected a  
logical comparison operator. Since typing `=' when you mean `==' is a fairly  
common mistake, it always warns you with the "Possibly incorrect assignement"  
message. 



More information about the Comp.lang.c mailing list