error C2381: ‘exit’ : redefinition;

C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(406) : error C2381: ‘exit’ : redefinition; __declspec(noreturn) differs
C:\Program Files\Microsoft Visual Studio 8\VC\include\GL/glut.h(146) : see declaration of ‘exit’
\sourceCode\main.cpp(362) : error C3861: ‘exit’: identifier not found

이러한 에러 발생시 해결법

(solution 1)

[before]

#include <GL/glut.h>

[after]

#include <stdlib.h>
#include <GL/glut.h>

(순서 주의!)

(solution 2)

glut.h 내용을 다음과 같이 수정해준다.

[before]

</pre>
#if defined(_WIN32)
# ifndef GLUT_BUILDING_LIB
extern _CRTIMP void __cdecl exit(int);
# endif
#else

[after]

</pre>
#if _MSC_VER>= 1200
_CRTIMP __declspec(noreturn) void __cdecl exit(int);
#elif defined(_WIN32) && !defined(GLUT_BUILDING_LIB)
extern _CRTIMP void __cdecl exit(int);
#else

Add a Comment