Constants in conditionals

Robert Osborne robert at isgtec.uucp
Wed Feb 20 04:54:27 AEST 1991


datangua at watmath.waterloo.edu (David Tanguay) writes:
> In article <9890 at dog.ee.lbl.gov> torek at elf.ee.lbl.gov (Chris Torek) writes:
> >Both of these are effectively the same as `if (0)', hence a good compiler
> >should warn about a constant in conditional context [...]
> 
> Oooo I hope not! I occasionally use constants in ifs.
Oooo I hope SO!  I occasionally use constants in ifs...
usually by mistake!   Since it is sort of a stupid thing
to do (why use an "if" when you already know which way you are
going to branch?) I would hope that it would produce a warning.

> "if( PATCH_MODE ) { ... }", where PATCH_MODE is a cpp macro (0 or 1).
> I know I coud use #if (or #ifdef), but I find them too ugly.
Nice attitude towards programming;
"I don't use any language constructs *I* don't find aesthetically pleasing"
I know that any compile dependency, whether for architecture, Unix type,
or to exclude some feature (ie. debugging), will have an
#if something
#endif
associated with it.
(Well, I at least at ISG I know this; now it seems this doesn't
extend to the whole world :-(
> I could also  use an external, but then I don't get
> the dead code elimination.
Oh now I see,  you left the smilee off your article.

Rob.
--
Robert A. Osborne   ...uunet!utai!lsuc!isgtec!robert or robert at isgtec.uucp



More information about the Comp.lang.c mailing list