PDA

View Full Version : GLUT and STDLIB are not getting along



DoggE
05-28-2004, 12:52 AM
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

ZbuffeR
05-28-2004, 02:06 PM
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.

Jonathan Sprinkle
06-11-2004, 11:55 AM
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---------

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

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?