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

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.

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. :slight_smile: I did a no-no and changed glut.h:144 to replace:

-------old---------

#if defined(_WIN32)
# ifndef GLUT_BUILDING_LIB
extern _CRTIMP void __cdecl exit(int);
#endif

-------new---------

 
#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. :slight_smile:

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?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.