ANSI C-compliant compiler (info req)

Doug Gwyn gwyn at smoke.BRL.MIL
Wed May 17 07:51:04 AEST 1989


In article <503 at bnr-fos.UUCP> klash at hobbes.UUCP (Karl Klashinsky) writes:
>I am curious about the existence of ANSI standard-conforming compilers.
>Are there any out there yet?  Are they commercial?
>Is there a GNU ANSI C compiler?

(Ignoring the fact that there isn't actually an ANSI standard quite yet.)
Several commercially available compilers claim to be standard-conforming
or at least "ANSI C compatible" (which seems to mean that they support
function prototypes, at least).  AT&T has promised to release one with
UNIX System V Release 4.0.  GCC seems to be fairly highly conforming from
what I have heard (for 100% conformance one supposedly has to specify a
couple of command-line options to override default behavior).  Certainly
most major C compiler vendors have expressed their intentions to provide
standard-conforming implementations as soon as possible.

>On a related note, can anybody tell me if there is going to be some
>kind of symbol defined so that I can 'ifdef' code for an ANSI compiler?

It's supposed to be __STDC__, but some vendors have already started to
define this as a variety of things for non standard-conforming
implementations.  We argued about this issue on comp.std.c not long ago.

__STDC__ is guaranteed to be predefined as 1 in a standard conforming
implementation.  Unfortunately you can't tell if it's undefined, defined
as 0, or defined as > 1 (which is supposed to be reserved for future C
standards) in a nonconforming implementation.  I think it has even been
defined as 1 in one blatantly nonconforming case.

I suggest you invent your own configuration macro, defined in your
system-configuration application standard header file (mine is called
"std.h") which you should have anyway if you're trying for portability.
For example, mine is defined as follows by default but can be edited to
hard-code the correct value in case a really bogus implementation is
encountered:

/* Defense against some silly systems defining __STDC__ to random things. */
#ifdef STD_C
#undef STD_C
#endif
#ifdef __STDC__
#if __STDC__ > 0			/* present and future Standard C */
#define	STD_C	__STDC__		/* use this instead of __STDC__ */
#endif
#endif

Then I use STD_C where one really ought to have been able to use __STDC__.



More information about the Comp.lang.c mailing list