expressions and #if

The WITNESS bsafw at ncoast.UUCP
Tue Jul 31 00:31:51 AEST 1984


> How about using the cpp #ifdef this way:
> 
> #ifdef	FEATURE
>	if (not_otherwise_indicated())
> #endif	FEATURE
> 		{
> 		process ();
> 		...
> 		}
> 
> To me it is just as clear (maybe even a little more) than saying:
> 
>	if (FEATURE == disabled || not_otherwise_indicated()) {
>		process ();
>		...
>		}
>

But not_otherwise_indicated() will be executed in the second version, and
I've seen a LOT of code that uses side-effects... in which case the second
version may do something disastrous.  If not_otherwise_indicated() is just
a simple Boolean test, however, it'll work (if not as fast as it might).
-- 
		Brandon Allbery: decvax!cwruecmp{!atvax}!bsafw
		  6504 Chestnut Road, Independence, OH 44131

		  Witness, n.  To watch and learn, joyously.



More information about the Comp.lang.c mailing list