__STDC__ and non-conforming ANSI C compilers
Tony L. Hansen
hansen at pegasus.ATT.COM
Sun Jan 15 15:35:08 AEST 1989
This is my understanding of what will be in the SVr4 compiler (according to
information which I've seen released). It will have 3 modes, selectable via
compiler options.
The default mode will be fully ANSI C conforming except for the fact that
the additional UNIX System functions will be declared within the header
files. Because of this exception, __STDC__ will be predefined to 0.
If the "fully-conforming" ANSI mode is chosen, __STDC__ will be
predefined to 1 and those extra functions will not declared.
(The 3rd mode is essentially the same as the first except that arithmetic
for unsigned integers use the old rules which are no longer true. I don't
recall the setting for __STDC__.)
Now these questions come up:
1) Should it declare the extra functions by default?
My feeling is yes. After all, this is for a UNIX System and
those functions should continue to be declared where they used
to be or else code will be broken.
2) Should it #define __STDC__ to be 1 by default?
First off, can it? Because it declares the extra functions,
does that prevent it from being a "fully conforming" ANSI
C compiler? If it weren't for those extra function declarations,
it would be indistinguishable from a "fully conforming" mode.
Perhaps it SHOULD #define __STDC__ as 1 for both modes.
3) Is the SVr4 C compiler useful with this scheme?
My feeling is yes. I can use "#ifdef __STDC__" to fully differentiate
within my code between the old K&R C and new ANSI C syntaxes.
4) Is it broken?
Well, it gives you a choice between the "fully conforming" mode
and the mode which declares those extra functions. You can easily
define an "ansicc" which does "cc -A" (or whatever the option is
called). It lets you distinguish fully between pre-ANSI mode,
ANSI mode and slightly-off-ANSI mode. Is it broken? I don't think
so.
By the way, I also reject the opinion that using -D when invoking an ANSI C
compiler:
ansicc -Dxyz
should suddenly cause __STDC__ to be undefined. (Sorry Doug, I think you're
wrong here.)
Tony Hansen
att!pegasus!hansen, attmail!tony
More information about the Comp.std.c
mailing list