[comp.std.c] A convention for defining __STDC__

gmt@arizona.edu (Gregg Townsend) (01/22/89)

In article <915@sfmin.UUCP> dfp@attunix.att.com (Dave Prosser) writes:
>I would propose that __STDC__ be #defined to be 0 in C compilation systems
>that meet all ANSI C conformance requires except for:
>  1. the inclusion of nonconforming "common extensions" listed in A.6.5,
>  2. not issuing otherwise required diagnostics when language extensions
>     are used, and/or
>  3. extra names declared or defined in standard headers.
>If __STDC__ is 1, the compilation system must be conforming.

This is a good solution and I encourage everyone to give it serious thought.

The most important function of __STDC__ is to distinguish between
old-style compilers (no prototypes, no token pasting, etc.) and new-style
ones.  This distinction will be testable by a simple  #ifdef __STDC__.

Some people also wish to test for perfect conformance to the standard, and
this is served by an equally simple  #if __STDC__==1  test. 

Certain current systems do give warnings on the second test because __STDC__
is undefined.  Avoiding these, if necessary, does add some complication; but
I firmly believe the first distinction is the more important, and should be
kept simple.

    Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
    +1 602 621 4325      gmt@Arizona.EDU       110 57 16 W / 32 13 45 N / +758m