Unix风格的操作系统
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
/* UNIX-style OS. ------------------------------------------- */
#endif
POSIX和POSIX版本
一旦你知道它是Unix,你可以找到它是POSIX和POSIX版本:
#include <unistd.h>
#if defined(_POSIX_VERSION)
/* POSIX compliant */
#endif
BSD派生系统
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
#include <sys/param.h>
#if defined(BSD)
/* BSD (DragonFly BSD, FreeBSD, OpenBSD, NetBSD). ----------- */
#endif
#endif
Linux
#if defined(__linux__)
/* Linux */
#endif
Apple操作系统
#if defined(__APPLE__) && defined(__MACH__)
/* Apple OSX and iOS (Darwin) */
#include <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR == 1
/* iOS in Xcode simulator */
#elif TARGET_OS_IPHONE == 1
/* iOS on iPhone, iPad, etc. */
#elif TARGET_OS_MAC == 1
/* OS X */
#endif
#endif
Windows与Cygwin
#if defined(__CYGWIN__) && !defined(_WIN32)
/* Cygwin POSIX under Microsoft Windows. */
#endif
非POSIX Windows
#if defined(_WIN64)
/* Microsoft Windows (64-bit) */
#elif defined(_WIN32)
/* Microsoft Windows (32-bit) */
#endif
本文深入剖析了Unix风格操作系统,包括其与POSIX标准的关系,特别关注了BSD派生系统、Linux、Apple OS X/iOS及Windows平台的Cygwin与非POSIX版本。详细介绍了各平台特有的头文件和条件编译,帮助读者理解不同操作系统的技术差异。

578

被折叠的 条评论
为什么被折叠?



