btw, i've tried something new: the -Wall (enable all warnings) flag of GCC -- so far, i was believing that i needn't warnings, because warnings were boring and didn't give any valuable information.
Hah! how f00lish was i ...
GCC pointed out dozen of uninitialized variables, tons of function that actually returned unpredictable value (often used as a true boolean) and a few "wrong parameters" due to the use of undeclared functions ...
So much horrors .. i even wonder how my code have worked for so long ...
Be wise, guyz. Put your code in the -Wall brick by brick, and do not wait until nothing works to try that marvelous option ...
Then study your C language book until you understand exactly what the compiler is complaining about and only then fix stuff.
a small example is
Code: Select all
if (var=constructor()) { ... } else fail("cannot construct object");
Code: Select all
if (( var=constructor() )) { ... }
now that it's written (( x=y )) i hope it will be easier to get convinced that it's an affectation plus a "non-null" test rather than a comparison.
Hope my experience will help you ...