Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: GLUT and STDLIB are not getting along

  1. #1
    Junior Member Newbie
    Join Date
    May 2004
    Location
    Brisbane, Australia
    Posts
    1

    GLUT and STDLIB are not getting along

    I'm sure that this is a simple matter, but for the life of me I cannot fathom why Visual Studio .NET likes to spits out:
    d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\stdlib.h(256) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs
    d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\GL\glut.h(146) : see declaration of 'exit'

    when Visual Studio 6 doesn't. I have done some looking about, and I have tried to change the exit function in glut.h without success, can anyone help me fix the problem?
    Any help would be appricated

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: GLUT and STDLIB are not getting along

    That reminds me of the glut atexit hack, you have to disable it :

    <quoted from the net>
    # Finally, the latest version of the glut.h is not fully compatible with .NET. I have taken steps to let it work; namely, by being careful to #include <stdlib.h> first, and disable the GLUT "atexit" hack. This fix is unstable, and may need updating in the future.
    </end quote>

    To be more specific, you have to do :
    #define GLUT_DISABLE_ATEXIT_HACK
    before including glut.h. You can have a lot at the explanation in the glut.h file.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2004
    Location
    Berkeley, CA
    Posts
    1

    Re: GLUT and STDLIB are not getting along

    Originally posted by ZbuffeR:
    To be more specific, you have to do :
    #define GLUT_DISABLE_ATEXIT_HACK
    before including glut.h. You can have a lot at the explanation in the glut.h file.
    Bzzzzt, this doesn't work. I did a no-no and changed glut.h:144 to replace:

    -------old---------
    Code :
    #if defined(_WIN32)
    # ifndef GLUT_BUILDING_LIB
    extern _CRTIMP void __cdecl exit(int);
    #endif
    .....

    -------new---------
    Code :
    #if defined(_WIN32)
    # ifndef GLUT_BUILDING_LIB
    //extern _CRTIMP void __cdecl exit(int);
    #if     _MSC_VER >= 1200
    _CRTIMP __declspec(noreturn) void   __cdecl abort(void);
    _CRTIMP __declspec(noreturn) void   __cdecl exit(int);
    #else
    _CRTIMP void   __cdecl abort(void);
    _CRTIMP void   __cdecl exit(int);
    #endif
    #endif
    ...
    -----------------

    Which is straight out of .NETs <stdlib.h> file. Incidentally, I have done most of my programming recently with STL, so I am not sure whether the following reflects only STL programming, but why do we not include <cstdlib> rather than <stdlib.h>?? I abandoned <stdlib.h> many years ago, but as i say, i have been using STLPort since years ago too.

    How do I go about submitting my .NET project files to be included with the source code release, so that others don't have to muck around with the VC6-->VC7 conversion like I did?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •