clib/sysenv.h
2023-10-22 21:43:47 +08:00

45 lines
1.1 KiB
C

#ifndef _SYSENV_H_
#define _SYSENV_H_
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#define _OS_WIN 1
//define something for Windows (32-bit and 64-bit, this part is common)
#ifdef _WIN64
#define _OS_WIN64 1
//define something for Windows (64-bit only)
#else
#define _OS_WIN32 1
//define something for Windows (32-bit only)
#endif
#elif __APPLE__
#define _OS_APPLE 1
#include <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR
#define _OS_APPLE_SIM 1
// iOS, tvOS, or watchOS Simulator
#elif TARGET_OS_MACCATALYST
#define _OS_APPLE_CATA 1
// Mac's Catalyst (ports iOS API into Mac, like UIKit).
#elif TARGET_OS_IPHONE
#define _OS_APPLE_PHO 1
// iOS, tvOS, or watchOS device
#elif TARGET_OS_MAC
#define _OS_APPLE_MAC 1
// Other kinds of Apple platforms
#else
# error "Unknown Apple platform"
#endif
#elif __linux__
#define _OS_LINUX 1
// linux
#elif __unix__ // all unices not caught above
#define _OS_UNIX 1
// Unix
#elif defined(_POSIX_VERSION)
#define _OS_POSIX 1
// POSIX
#else
# error "Unknown compiler"
#endif
#endif //_SYSENV_H_