Reserved names in ANSI C

david.f.prosser dfp at cbnewsl.ATT.COM
Sun Jul 2 00:19:34 AEST 1989


In article <362 at mountn.dec.com> minow%thundr.dec at decwrl.dec.com (Martin Minow) writes:
>If the problem were only limits.h, or only stdio.h, or only ctype.h,
>there would be no objection, but the library is, in reality, a monolith
>of a dozen or so packages with a total of several hundred names, with a
>variety of syntactic patterns.  I shouldn't be expected to memorize
>all these names or their syntactic patterns.

We all sympathize with your point here, and you're right at least for me:
I need to go back and check in certain situations since the rules are
pretty complex and some of the patterns not simple...the worst is the
<math.h> reservations since one has to know all the names of the functions
in <math.h> before the reserved name space is known.

>
>The application environment has gotten steadily more complex in the
>ten or twelve years since C left its original home.  I see nothing to
>suggest that the environment will become simpler (indeed, quite the
>opposite). 

Quite correct.  The growing complexity was what served as X3J11's existing
practice...

>
>I wish that, along with reserving a wide variety of lexical patterns
>to Ansi,  some set of patterns were reserved to application programs.
>For example, on VMS, XXX$<anything> is explicitly reserved to VMS
>development (and a development group must reserve its private XXX header),
>while XXX_<anything> is explicitly reserved to user development.

Pretty much the entire Committee probably wishes something along these
lines.  It's not that I disagree with your points, it's just that the
existing implementations govern what gets standardized.  There was just
no way for X3J11 to do any better than it did.  With the exception of
the few new library functions introduced by X3J11 (such as those for
multiple locale and multibyte character handling), every name noted as
reserved was already "reserved" in the existing C world.  X3J11 made
things better, actually, since it "put on the breaks" as soon as it could.

>
>As a software architect, one of my primary tasks is managing complexity.
>If, for example, ANSI reserves <letters> '__' <letters-or-digits> to
>application programs, I could write standard-conforming programs without
>worrying that version 2, 3, or whatever of the standard conflicted with
>my code.

For the most part, there is are some simple rules that you can use to
prevent your conflicting with the reserved name space:  If you write
all your file scope and external linkage names with at least one
underscore as the second, third, or fourth character, but not the first,
you'll be in good shape.  This rule doesn't help with macros in general,
but since macros are only reserved when their respective header is
included, keeping track of macros is easier.

>
>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