不想细究的同学,按照图所示修改,简单明了;
或者在主文件 include 头文件之前加上下面几行代码
#ifndef WIN32
#define WIN32
#endif
查找错误根源:
首先双击VC错误列表第一项(从前往后改正bug是一个良好的习惯!)跳转到发生编译错误的代码行,例如:
WINGDIAPI 是这个文件中第一个错误提示处(绝大部分错误最初的源头就在这个符号)。
接下来在整个磁盘中查找WINGDIAPI 的定义。
#ifndef WIN32
// Required for compatibility with glext.h sytle function definitions of
// OpenGL extensions, such as in src/osg/Point.cpp.
#ifndef APIENTRY
#define APIENTRY
#endif
#else // WIN32
#if defined(__CYGWIN__) || defined(__MINGW32__)
#ifndef APIENTRY
#define GLUT_APIENTRY_DEFINED
#define APIENTRY __stdcall
#endif
// XXX This is from Win32's <windef.h>
#ifndef CALLBACK
#define CALLBACK __stdcall
#endif
#else // ! __CYGWIN__
// Under Windows avoid including <windows.h>
// to avoid name space pollution, but Win32's <GL/gl.h>
// needs APIENTRY and WINGDIAPI defined properly.
// XXX This is from Win32's <windef.h>
#ifndef APIENTRY
#define GLUT_APIENTRY_DEFINED
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
#define WINAPI __stdcall
#define APIENTRY WINAPI
#else
#define APIENTRY
#endif
#endif
// XXX This is from Win32's <windef.h>
#ifndef CALLBACK
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
#define CALLBACK __stdcall
#else
#define CALLBACK
#endif
#endif
找到这段代码,从WINGDIAPI 开始找起。考验阅读代码的时刻。