Opengl cpp代码在windows和mac上运行?

nit*_*h99 0 c++ windows opengl macos if-statement

我想知道是否有任何if语法可用于在mac和windows上运行opengl c ++代码.更具体地说,在代码的开头,我可以设置一个if条件来确定代码是在mac(通常是xcode)还是windows(通常是visual c ++)上运行,并相应地包含头文件.

小智 5

您可以使用预处理器#ifdef.

#ifdef __APPLE__
#ifdef TARGET_OS_MAC

  #include <osx.h>

#endif
#elif defined(_WIN32) || defined(_WIN64)

  #include <win.h>

#endif
Run Code Online (Sandbox Code Playgroud)