Microsoft KB Archive/243444

= You receive a C2653 or C2039 error message when you try to reference a function from the STD C++ library =

Article ID: 243444

Article Last Modified on 5/26/2005

-

APPLIES TO


 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q243444



SYMPTOMS
Attempting to reference a function from the STD C++ library header using the namespace STD (for example, std::exit(0)) causes the compiler to emit a C2653 or a C2039 (depending upon whether or not namespace "STD" is defined at the point where the error is emitted).



CAUSE
does not define the namespace "STD". This is contrary to the VC++ documentation, which says:

"Include the standard header to effectively include the standard header  within the std namespace."



RESOLUTION
To work around the problem, place the "#include " in the namespace "STD".



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.



MORE INFORMATION
Attempting to compile the following will cause the compiler to display the following error:

"error C2653: 'std' : is not a class or namespace name"

// Compile Options: /GX
 * 1) include

void main {    std::exit(0); } However, attempting to compile the following causes the compiler to display the following error:

"error C2039: 'exit' : is not a member of 'std'"

// Compile Options: /GX
 * 1) include
 * 2) include

void main {    std::exit(0); }

In the first case, the C2653 is displayed, because the namespace "STD" has not been defined. In the second case, the C2039 is displayed, because the namespace "STD" has been defined (in the header ), but the function exit is not part of that namespace. To work around the problem in either case, simply enclose the "#include " in the namespace "STD", as follows: // Compile Options: /GX namespace std { };
 * 1) include

void main {    std::exit(0); }

Keywords: kberrmsg kbtshoot kbbug kbcpponly kbpending kbcompiler KB243444

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.