__STDC__ and non-conforming ANSI C compilers

Mike Coffin mike at arizona.edu
Wed Jan 18 06:25:17 AEST 1989


>From article <9405 at smoke.BRL.MIL>, by gwyn at smoke.BRL.MIL (Doug Gwyn ):
>>3) I suppose there is a need to determine whether the compiler is
>>   exactly "conforming", although I'm not sure what you would do if it
>>   wasn't.  But the need is far more pressing for a flag that answers
>>   the question "is this a K&R compiler or an ANSI compiler?"  How do
>>   we tell the difference between a K&R compiler and an ANSI compiler
>>   that is invoked in such a way that it's nonconforming?  (E.g., 
>>   "cc -DFOO".)  Does the standard say anything about this?  Shouldn't 
>>   we adopt some convention before we have chaos?
> 
> I don't know what you mean by a "K&R compiler".  Existing UNIX compilers
> do not conform to either K&R or the pANS.  From my perspective, the MOST
> important distinction is between C environments that follow the Standard
> (in which case I know EXACTLY what to expect) and ones that don't.  The
> latter category is just as messed up as it has ALWAYS been, and no
> single test is sufficient to untangle THAT mess.  However, we should
> adhere very strictly to the use of __STDC__ to distinguish between the
> well-defined case and the myriad of random implementations.  Dragging
> __STDC__ into the morass merely ruins its utility; it doesn't help the
> user of an uncontrolled C environment to determine anything reliable.

Thanks for the answers, most of which I'll buy.  This one I still have
trouble with.  

I still say, the most important distinction is between C environments
that "essentially" follow K&R and those that "essentially" follow
pANS.  I will grant you that "essentially" is an imprecise term, but
this is still the important question.  (I can't define a K&R compiler,
but I know one when I see it :-) Previous implementations of C adhered
more or less to one (de facto) standard, future ones will adhere more
or less to pANS.  In a lot of situations I want to know which.  E.g.
   * should I use function prototypes?
   * can I assume that parenthesis will control evaluation order?
   * how do I splice tokens?
   * should I include <varargs> or <stdargs>?
These are practical problems, for which I see no solution at the
moment.

Strict compliance isn't something that buys me much.  I don't have
much use for a flag that will get turned off if the compiler is
invoked with "cc -DDEBUG".  Where will I use it?
-- 
Mike Coffin				mike at arizona.edu
Univ. of Ariz. Dept. of Comp. Sci.	{allegra,cmcl2}!arizona!mike
Tucson, AZ  85721			(602)621-2858



More information about the Comp.std.c mailing list