Re: Using the phrase "ISO C++ conformant" (was: Name change to MSDN C++/CLI column)
Seungbeom Kim wrote:
When I looked up the function "read" in MS Visual Studio 2005,
I got the following help:
Run-Time Library Reference
read
This POSIX function is deprecated beginning in Visual C++ 2005.
Use the ISO C++ conformant _read instead.
I suspect Microsoft is not entitled to say that _read is "ISO C++
conformant"; in which way is _read more ISO C++ conformant than read?
Let us think about this question logically. For "_read" to be compliant
with the Standard while "read" is not, it stands to reason that "_read"
must have something that "read" lacks. If only we could determine what
that "something" is - we would be able to solve the mystery. But "read"
and "_read" certainly look alike... wait, I have an idea, what if
compare them like this:
read
_read
With this stroke of genius, the piece of the puzzle that has been
missing now falls into place. The subtle difference that eluded
detection now looks obvious: "_read" has a leading underscore that
"read" lacks. So it must be the presence of this underscore that makes
"_read" compliant and it must be the absence of the same underscore
that makes "read" noncompliant.
So let's see what the Standard has to say about global names and
leading underscores:
"Each name that begins with an underscore is reserved to the
implementation for use as a name in the global namespace."
?17.4.3.1.2/1
So there we have it. "_read" is a name in the global namespace reserved
for the implementation (that would be Microsoft in this case) - while
"read" has not been reserved. Furthermore, Microsoft should not be
creating names in the global namespace that have not been reserved for
it. Because were Microsoft to go ahead and declare a "read" function in
the global namespace then that name could conflict with a user-defined
"read" symbol. By renaming the function "_read", Microsoft is complying
with the ISO C++ Standard by ensuring that the name is one that only
Microsoft is allowed to declare as a global name.
Greg
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]