Mail Archives: djgpp/1996/11/02/04:43:09
Dave Cigna (cigna AT helios DOT phy DOT OhioU DOT Edu) wrote:
: A little trick that (I never use, but seems kind of cool anyway):
: if(0 = A)
:
: instead of
: if(A = 0)
: will always generate an error, even without -Wall.
: -- Dave Cigna
Actually that trick, which I heard from a more experienced user
not so long ago, is a theme of my next C column <grin>. As I note there,
the GCC warning is very helpful and descriptive, more or less:
suggest parentheses around assignment used as truth value
That identifies the possible mistake and nicely reinforces the
distinction in question at the same time.
When editing and compiling inside of Emacs 19.31, I use a makefile
with the -Wall option; that makes it easy to get information on possible
glitches of this kind.
I'm not sure why, but the tendency to put the variable before the
constant in an equality test seems very strong <grin>.
Margo Schulter
mschulter AT mpu DOT com
MSDOG
Slowly
Develops
Opulent
GNUness
- Raw text -