Constants in conditionals, was Re: Are enums safe to use in portable code?

David Tanguay datangua at watmath.waterloo.edu
Mon Feb 18 22:39:19 AEST 1991


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.
"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. I could also
use an external, but then I don't get the dead code elimination.
-- 
David Tanguay            Software Development Group, University of Waterloo



More information about the Comp.lang.c mailing list