eli.fried
...@gmail.com wrote:
> The C++ standard says that "Each name that contains a double
> underscore _ _ or begins with an underscore followed by an uppercase
> letter (2.11) is reserved to the implementation for any use." The
> equivalent section of C99 says "All identifiers that begin with an
> underscore and either an uppercase letter or another underscore are
> always reserved for any use." Is it intentional that using
> identifiers like kw__for (with two underscores) is legal in C but not C
> ++? If so, why?
The original motivation behind reserving all uses of __ to the
implementation was to provide a mechanism for name mangling (i.e.
encoding the function signature in the name used by the compiler) While
there are other ways that name mangling (or more generally overloading
of function names) could have been supported the choice was motivated by
the need to support code translators (e.g. CFront)that converted C++
code to C and so needed to keep withing the character set supported by C.
Changing that rulle would require a rewrite of sections of most current
C++ implementations to no great gain.
In practice __ is rarely used in C and where it is a C++ compiler will
normally be able to cope with it.
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-...@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]