Constants in conditionals
Paul Tomblin
pt at geovision.gvc.com
Sat Feb 23 03:59:46 AEST 1991
jef at well.sf.ca.us (Jef Poskanzer) writes:
>In the referenced message, pt at geovision.gvc.com wrote:
>}Sorry, but #ifdef or #if is SOOO basic, that if you don't know how to use
>}it (or refuse to for wierd reasons), you loose.
>Using "if" for conditional compilation instead of "#if" has one major
>advantage: the outshipped code continues to get checked for syntax
>errors. For machine-dependent code you probably don't want this,
>otherwise you probably do. But you're right, you do have to check
>the generated assembly code to make sure your compiler is doing
>the right thing. These days, most do.
I think you'd be making a mistake in assuming that because code still
compiles without error that it is still correct. "If it's not exercised,
it's not correct" is a good assumption that any future maintainer of the code
would have to make. Code around here that is "#if 0"ed out, is usually
expunged the next time a bug shows up it that area of code. If it's
"if (FALSE)"ed out, it will be expunged the first time it's spotted.
(And the coder will get a talking to! PCC doesn't do the right thing.)
We use #ifdef for two reasons: Machine dependant code, and debugging.
When trying out new things, or temporarily removing something to try
another approach, we tend to put in #ifdefs, but we try and remove them
when we are done. Anything else is asking for maintainence headaches.
(I know, I'm in charge of maintainence!)
--
Paul Tomblin, Department of Redundancy Department. ! My employer does
The Romanian Orphans Support Group needs your help, ! not stand by my
Ask me for details. ! opinions....
pt at geovision.gvc.com or {cognos,uunet}!geovision!pt ! Me neither.
More information about the Comp.lang.c
mailing list