Topic: reserved identifiers in ANSI/ISO standard
Author: jackklein@att.net (Jack Klein)
Date: 1999/06/21 Raw View
There is a question that comes up periodically on programming
newsgroups which cover C++, that of reserved identifiers.
The standard reserves names starting with "underscore + upper case"
and "underscore underscore" for the implementations in all contexts,
just like standard C, and also containing "underscore underscore"
anywhere in them, unlike C.
It doesn't mention symbols starting with "underscore + lower case"
which in C are reserved for the implementation at file scope.
My assumption that in standard C++ they are reserved at file scope in
at least the global and std namespaces because C headers can be
included in either namespace.
But I would like a more definitive answer if one is available. Should
symbols beginning with an underscore and a lower case letter be
considered reserved as I mentioned in the paragraph above? Should
they be considered reserved in any other situations?
I assume they can be used as typenames and member names, or is that
incorrect?
Jack
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: clamage@eng.sun.com (Steve Clamage)
Date: 1999/06/22 Raw View
jackklein@att.net (Jack Klein) writes:
>The standard reserves names starting with "underscore + upper case"
>and "underscore underscore" for the implementations in all contexts,
>just like standard C, and also containing "underscore underscore"
>anywhere in them, unlike C.
>It doesn't mention symbols starting with "underscore + lower case"
>which in C are reserved for the implementation at file scope.
Section 17.4.3.1.2 "Global names" says:
"Each name that begins with an underscore is reserved to the
implementation for use as a name in the global namespace."
Everything at file scope is in the global namespace by definition.
--
Steve Clamage, stephen.clamage@sun.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 1999/06/23 Raw View
Jack Klein wrote:
>
> There is a question that comes up periodically on programming
> newsgroups which cover C++, that of reserved identifiers.
>
> The standard reserves names starting with "underscore + upper case"
> and "underscore underscore" for the implementations in all contexts,
> just like standard C, and also containing "underscore underscore"
> anywhere in them, unlike C.
>
> It doesn't mention symbols starting with "underscore + lower case"
> which in C are reserved for the implementation at file scope.
17.4.3.1.2, p1: "Each name that begins with an underscore is reserved to
the implementation for use as a name in the global namespace. 165)"
Footnote 165 notes that 17.4.3.1 means that these names are also
reserved in the namespace ::std.
> My assumption that in standard C++ they are reserved at file scope in
> at least the global and std namespaces because C headers can be
> included in either namespace.
Yes.
> But I would like a more definitive answer if one is available. Should
> symbols beginning with an underscore and a lower case letter be
> considered reserved as I mentioned in the paragraph above? Should
No, it's already covered.
> they be considered reserved in any other situations?
I think you've covered it.
> I assume they can be used as typenames and member names, or is that
> incorrect?
Not as typenames in the global namespace or in namespace ::std. Member
names should be safe.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]