#if foo vs #if defined(foo)

ron at brl-sem.UUCP ron at brl-sem.UUCP
Sun Jul 13 05:10:37 AEST 1986


In article <379 at twitch.UUCP>, grt at twitch.UUCP ( G.R.Tomasevich) writes:
> Our compiler does not need a defined(), or at least I did not try whether
> it is even accepted.  The following example works fine:
> 
> #if squat||foo

Consider an optionally included definition

#define	SQUAT	0

If your code really wanted to check for this then the proper
test would be

#if defined(SQUAT) && (squat == 0)

to differentiate between undefined SQUAT and SQUAT defined but
equal to zero.



More information about the Comp.lang.c mailing list