在Mac OS X SDK中有一个头文件TargetConditionals.h,里面包含了应用运行目标的宏定义,下面是示例代码:
#ifdef __APPLE__
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE | TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#define OPENGL_ES
#else
#include <GL/glew.h>
#include <OpenGL/gl.h> // Apple OpenGL headers (version depends on OS X SDK version)
#endif
#endif