Reserved names in ANSI C

david.f.prosser dfp at cbnewsl.ATT.COM
Thu Jun 22 23:11:28 AEST 1989


In article <316 at mountn.dec.com> minow%thundr.dec at decwrl.dec.com (Martin Minow) writes:
>Kenneth Almquist asks what namespace is reserved by Ansi C.
>
>Several people responded with various lexical patterns.  Unfortunately,
>none of the Drafts I've seen ever specified the totality of the namespace.

If it isn't reserved in the pANS, then it's not reserved.  Period.  Thus,
by definition, the "totality" of the reserved namespace is specified.

>We know that the C keywords and anything beginning with underscore are
>reserved, but there does not seem to be a limit on the library namespace.

There is a fixed set of names and some extension patterns based on the
names already included by that header.  This is clearly based on existing
practice.

>When I complained about this in one of the public reviews, I was told that
>this was for "Posix compliance."

I don't know what particular item you are referring to here, and the answer
of "Posix compliance" cannot by itself be an X3J11 motivation.

>
>I suspect that the namespace will continue to grow without bound, and the
>best you can do to avoid polluting (or being polluted) is to define all
>of your variables using some "private" initial sequence:
>
>	extern int	my_private_global_foo;
>	static int	my_private_local_bar;
>
>(I have much the same problem on the Macintosh, and define all of my
>variables in lower-case with an embedded underscore to avoid Macintosh
>system definitions, most of which use mixed case without underscores.)

This may well be a reasonable approach.  Despite X3J11's best efforts to
control the namespace, most vendors will continue to pollute the programmers'
namespace.  X3J11 found itself in a fairly painful position on this issue:
Half the comments on the namespace were of the "X3J11 has reserved more names
than COBOL--what's going on here!?" variety and the other half were "X3J11
has made it impossible to implement <whatever> due to its overly restrictive
namespace--remove these silly limits!"

What X3J11 has successfully done is made it possible to write useful C
programs that require not a single character to be changed to compile and
run on every hosted ANSI C conforming implementation.  Without the fixed
limits on namespace, this would never have been possible.  Moreover, the
pANS also provides enough escape clauses to allow implementations the
freedom necessary to provide their extensions.  Of course, in some cases,
the job is a little difficult for both types of X3J11 users--this is a
natural result of walking the middle ground.

>
>Martin Minow
>minow%thundr.dec at decwrl.dec.com
>The above does not represent the position of Digital Equipment Corporation.

Dave Prosser	...not an official X3J11 answer...



More information about the Comp.std.c mailing list