Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!iuvax!rutgers!bellcore!ctt.bellcore.com!sjs From: sjs@ctt.bellcore.com Newsgroups: comp.std.c Subject: Re: __STDC__ and non-strictly conforming ANSI C compilers Keywords: ANSI C, __STDC__, near, far, flexnames Message-ID: <12666@bellcore.bellcore.com> Date: 15 Dec 88 21:29:17 GMT References: <3236@pegasus.ATT.COM> <9167@smoke.BRL.MIL> <12643@bellcore.bellcore.com> <9187@smoke.BRL.MIL> <11005@ulysses.homer.nj.att.com> Sender: news@bellcore.bellcore.com Reply-To: sjs@ctt.bellcore.com (Stan Switzer) Lines: 54 In article <9187@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: > > Note that macros such as "near" can be defined (as "__near", for > example) in any non-standard header, as well as under control of > compiler options or a special non-ANSI, backward-compatible > version of the cc command. The constraints against pollution of > the name space by implementations is a great advance in sanity > and should be taken quite seriously. Proposing that a compiler which conforms but for the addition of a few keywords should define __STDC__ Jerry Schwarz asks: > > Does the answer depend on which of the following commands is used > to invoke the non-conforming compiler? > > xcc prog.c > cc -extended prog.c > cc -Dnear=__near prog.c This is fine as long as there is SOME set of options, preferably the default, under which "near", "far", and, for that matter, all other identifiers are just that: identifiers. The important question is whether a __STDC__ compiler can be counted upon to compile strictly conforming programs. The following fragment illustrates my point: # include int near( int i, int j ) { return ( abs(i-j) < 10 ); } If "near" is a reserved keyword this will not compile even though it is strictly conforming. It is much better for ALL reserved words introduced for extensions to begin with "_" and be mapped from non-underscore values only when requested via an option or an include file. I'm not saying that vendors shouldn't add extensions, just that they should do it without encroaching on the user's name space. The X3J11 committee as provided perfectly good and totally painless way of doing this without breaking programs. Any compiler that doesn't bother to do it that way shouldn't go around defining "__STDC__". Probably by now most of us will avoid using the identifier "near" in our programs because we know that it is a keyword in some compilers. But this is a point of principle: what other identifiers must we now worry about? Perhaps we'll have to start a newsletter to keep track of the identifiers to avoid because some vendor or another has made it a keyword. Let's not let compiler vendors undermine the good work of the committee toward ending name space pollution. Stan Switzer sjs@ctt.bellcore.com