Standardization questions (cpp mostly)

Ken Turkowski ken at turtlevax.UUCP
Mon Oct 8 14:55:47 AEST 1984


> WHAT IS WRONG
> A predefined variable is produced with explicit code in cpp,
> with the '-Dvax' argument to cpp, or with '#define vax 1'
> The result is that 'vax' evaluates to '1', which is fine if
> people want to say '#ifdef vax' or (gag me) '#if vax'
> but not so hot if you want to compile a portable (hear hear!)
> program that happens to use 'vax' as a variable.
> 
> THE FIX
> We should return to the old days when vax was really 'vax',
> unix was really 'unix', and small furry creatures were still single.
> Here is a weak attempt at how it might be worded:
> 	The effect of '#define foo foo' and also '-Dfoo' as an option
> 	will be to make 'foo' defined and to evaluate to itself.
> 	Subsequently, foo and defined(foo) will both evaluate to 1
> 	within a #if, foo will be considered defined within a #ifdef
> 	or #ifndef, and foo will have no special meaning elsewhere.
> 
> DISCUSSION
> This change is minor and would not break any existing programs.
> People need no longer live in fear of the 'printf' machine
> that is to be announced early next year.
> 
> I am not sure if '#define unix unix' should be handled as
> a special case (ordinarily it would result in a cpp loop),

The C preprocessor used to behave as you desire on version 6.  I seem
to recall documantation that implied that special code was used to
prevent infinite looping.
-- 
Ken Turkowski @ CADLINC, Palo Alto, CA
UUCP: {amd,decwrl,flairvax,nsc}!turtlevax!ken
ARPA: turtlevax!ken at DECWRL.ARPA



More information about the Comp.lang.c mailing list