G
Gavin Deane
Illegal? You keep repeating this sentence.Please define illegal; I
think that must mean something syntactically wrong,
No. It's not a syntax error to use a name reserved to the
implementation. It is a violation of one of the (many) rules in the C+
+ standard that tell you what you are and are not allowed to write in
a C++ program.
<quote>From the standard:
17.4.3.1.2
Certain sets of names and function signatures are always reserved to
the implementation:
- Each name that contains a double underscore (_ _) or begins with an
underscore followed by an uppercase letter is reserved to the
implementation for any use.
- Each name that begins with an underscore is reserved to the
implementation for use as a name in the global namespace.
</quote>
And just before that in 17.4.3.1/3
<quote>
If the program declares or defines a name in a context where it is
reserved, other than as explicitly allowed by this clause, the
behavior is undefined.
</quote>
The "explitly allowed" part is talking about template specialisations
within namespace std - nothing to do with what we are discussing here.
So for the purposes of this discussion you can assume 17.4.3.1/3 says
"If the program declares or defines a name in a context where it is
reserved the behavior is undefined."
Is the meaning of any of that unclear to you?
but if you mean
none-std then I would humblly ask why is it none-std?
There are two parts to the answer to that question:
1. This rule provides a "namespace" that implementors use and you
avoid, thereby ensuring no name clashes between the implementation and
your code.
2. Further in-depth discussion of *why* the standard is the way it is
belongs in comp.std.c++. In this forum it is sufficient to say "Those
are the rules and you have to stick to them".
You have had both those parts of the answer before in this thread. Did
you not read them?
By the way thanks to everyone I have found that underscored names are
supposed to be used by implementors and others including third-party
libraries had better keep off them(it is not a must).
I have not seen anyone tell you here that "it is not a must". Whoever
told you it is not a must has mislead you. The standard is extremely
clear. If your code uses reserved names, the behaviour of your program
is undefined. Do you know what that means?
Gavin Deane