locked
error C2039: 'exit' : is not a member of '`global namespace''|

    Question

  • I have tried to get my Ogre3d to work with VC++ and Code::blocks according to Ogre3d's own installation guide.
    I'm running on an Vista 64.
    Now I'm getting these two errors:

    error C2039: 'exit' : is not a member of '`global namespace''|
    error C2873: 'exit' : symbol cannot be used in a using-declaration|

    I wonder how to fix this

    Friday, March 26, 2010 1:34 AM

Answers

  • >I wonder how to fix this

    By correcting the code. There is very little
    help that can be offered when there is so
    very little information provided. Do you
    really believe we're good enough to be
    able to debug code we've never seen? '-)

    At the very least, you need to show the
    lines of code which produced the compile
    error messages. That shouldn't be too
    hard, as the error message usually gives
    the line number in the source code. But
    be sure to use Windows copy & paste to
    put the source into a message here, do NOT
    try to reproduce it by typing it in. That
    usually results in disparities.

    You should always state which version and
    which edition of VC++ you are using, as
    it may affect the answers.

    - Wayne

    • Marked as answer by Wesley Yao Thursday, April 01, 2010 3:01 AM
    Friday, March 26, 2010 2:43 AM

All replies

  • >I wonder how to fix this

    By correcting the code. There is very little
    help that can be offered when there is so
    very little information provided. Do you
    really believe we're good enough to be
    able to debug code we've never seen? '-)

    At the very least, you need to show the
    lines of code which produced the compile
    error messages. That shouldn't be too
    hard, as the error message usually gives
    the line number in the source code. But
    be sure to use Windows copy & paste to
    put the source into a message here, do NOT
    try to reproduce it by typing it in. That
    usually results in disparities.

    You should always state which version and
    which edition of VC++ you are using, as
    it may affect the answers.

    - Wayne

    • Marked as answer by Wesley Yao Thursday, April 01, 2010 3:01 AM
    Friday, March 26, 2010 2:43 AM
  • I am having the same issue. I am using both Micorsoft Visual Studio C++ 2010 Express and Visual Studio 2010 Professional and am getting the same errors in both. The code I am running is Very simple.

    #include <iostream>


    int main() {
        std::cout << "Hello World!" << std::endl;
        std::cin.get();
        return 0;
    }

     

    But am getting the following Build error.

    1>------ Build started: Project: HardikBhattAssg2, Configuration: Debug Win32 ------
    1>  main.cpp
    1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(24): error C2039: 'exit' : is not a member of '`global namespace''
    1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(24): error C2873: 'exit' : symbol cannot be used in a using-declaration
    1>c:\documents and settings\hbhatt\my documents\gradschool\projecName\projecName\projecName\main.cpp(26): error C3861: 'exit': identifier not found
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

     

    Any help would be great.

    Thursday, March 17, 2011 1:42 PM
  • That's odd. Compiles and links just fine for me.
    Thursday, March 17, 2011 3:29 PM
  • From what I have researched it seems to be a .NET issue. It seems to have a corrupted cstdlib file. I am currently using Visual Studio 2010 Professional. If I may as which version of VS did u use to compile this code??
    Thursday, March 17, 2011 3:48 PM
  • It compiles for me using Visual Studio 2010 Ultimate, as well as Visual Studio 2010 Express.
    Friday, March 18, 2011 3:47 AM
  • SOLUTION FOUND:

    I have researched this issue on the web and it seems like it is something that has been an issue for a lot of people. The solution to this is as simple as removing a comment.

    I looked through the stdlib.h file, and found the the following line was commended out:

    _CRTIMP __declspec(noreturnvoid __cdecl exit(__in int _Code);

    I took out the comment and recompiled it ... and now it works.

    I believe in some builds the stdlib.h file will automatically be compiled with that portion of the code commented out. simple uncomment and your code will work.

    • Proposed as answer by pvdg42MVP Tuesday, April 24, 2012 9:32 PM
    Friday, March 18, 2011 1:22 PM
  • I have the same question,but had solved just like you said. but why?
    Wednesday, December 28, 2011 12:48 PM
  • This definition conflicts with other definitions of exit found in various libraries used in other environments besides that of Microsoft Windows.

    So it sometimes gets commented out.  People forget to uncomment it later when they link to some other library.

    Tuesday, April 24, 2012 8:57 PM