[ 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 ]
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.
> If so, why?
Historical reasons. Some early C++ compilers used C as an
intermediate language. Internally generated symbols used double
underscore, which is legal in C; by forbidding it in C++, they
ensure that these symbols can never conflict with a user defined
James Kanze (GABI Software) email:james...@gmail.com
Conseils en informatique orient�e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34