Pie*_*tro 12 unix macos macros
我注意到在MacOS X(Lion)中,__unix__没有定义宏.由于MacOS源于BSD UNIX,不应该是这样吗?
是否有可能让编译器/预处理器知道我希望它被视为UNIX系统?
Fle*_*exo 13
该预定义宏网站建议使用:
#if defined(unix) || defined(__unix__) || defined(__unix)
# define PREDEF_PLATFORM_UNIX
#endif
Run Code Online (Sandbox Code Playgroud)
区分UNIX系统.他们还有关于许多编写器的警告说明,这些编译器没有设置任何这些.根据您关心平台的原因,您可能最好不要考虑配置时间(在configure.ac您正在使用的构建系统中).
我认为这个网站提供了最全面的答案.
简而言之,要包括Apple平台和常见的Unix平台,您需要:
#if defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__))
...
#endif
Run Code Online (Sandbox Code Playgroud)