draft ANSI standard: major, quiet, unnoticed change

John Gilmore gnu at hoptoad.uucp
Tue Dec 2 15:15:35 AEST 1986


[This is posted to comp.lang.c because mod.std.c seems to be dead.  Love
those mod groups!]

The standard's rationale tries to mark as "QUIET CHANGES" any change
in the definition of C that would make a previously working program
quietly take on some new meaning, without any warning or error report.
Unfortunately, they missed a few.

The new standard disallows an implementation's pre-#defining any words
that don't begin with _ (section 3.8.8, "No macro names without a
leading underscore shall be predefined.").  This breaks all the code
that uses 

#ifdef vax
or
#ifdef unix
or
#ifdef sun

or all the other little predefines we've come to know and love.

Of course, the committee can say "well, they can just change their
Makefile every time they port that code" but it is definitely a change
that breaks large bodies of existing code.  Besides, do you want to
add -Dunix -Dsun -Dmc68000 to every compile you ever run?

One possible workaround is a set of configuration #define's which 
are only visible to #if and #ifdef, not to program code.  Yes, this is
a kludge, but I think it is less of a kludge than breaking all that code
or letting anybody predefine any name (the Main Computer Company will have
a rough time predefining #ifdef main...).

#pdefine sun

would cause #if sun or #if defined(sun) or #ifdef sun to be true, but
would not replace occurrances of "sun" in program text.  Presumably an
implementation could more freely have a set of these "pdefines"
predefined, since they would not cause trouble to innocent program
code, just to innocent preprocessor lines.
-- 
John Gilmore  {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu   jgilmore at lll-crg.arpa
    "I can't think of a better way for the War Dept to spend money than to
  subsidize the education of teenage system hackers by creating the Arpanet."



More information about the Comp.lang.c mailing list