// vim:fileencoding=utf-8:foldmethod=marker #ifndef PLATFORM_H #define PLATFORM_H // Operating system #if defined(__ANDROID__) #define WP_PLATFORM_ANDROID #define WP_PLATFORM_POSIX #elif defined(__FreeBSD__) #define WP_PLATFORM_FREE_BSD #define WP_PLATFORM_BSD #define WP_PLATFORM_POSIX #elif defined(__NetBSD__) #define WP_PLATFORM_NET_BSD #define WP_PLATFORM_BSD #define WP_PLATFORM_POSIX #elif defined(__OpenBSD__) #define WP_PLATFORM_OPEN_BSD #define WP_PLATFORM_BSD #define WP_PLATFORM_POSIX #elif defined(__DragonFly__) #define WP_PLATFORM_DRAGON_FLY #define WP_PLATFORM_BSD #define WP_PLATFORM_POSIX #elif defined(__bsdi__) #define WP_PLATFORM_BSD #define WP_PLATFORM_POSIX #elif defined(__linux__) || defined(linux) || defined(__linux) || defined(__gnu_linux__) #define WP_PLATFORM_LINUX #define WP_PLATFORM_POSIX #elif defined(__GNU__) || defined(__gnu_hurd__) #define WP_PLATFORM_GNU #define WP_PLATFORM_POSIX #elif defined(__APPLE__) || defined(__MACH__) #include #if TARGET_OS_IPHONE #define WP_PLATFORM_IOS #define WP_PLATFORM_APPLE #define WP_PLATFORM_POSIX #elif TARGET_OS_MAC #define WP_PLATFORM_MACOS #define WP_PLATFORM_APPLE #define WP_PLATFORM_POSIX #else #error "Unrecognised Apple platform" #endif #elif defined(_WIN64) #define WP_PLATFORM_WINDOWS64 #define WP_PLATFORM_WINDOWS #elif defined(_WIN32) #define WP_PLATFORM_WINDOWS32 #define WP_PLATFORM_WINDOWS #elif defined(__CYGWIN__) #define WP_PLATFORM_CYGWIN #define WP_PLATFORM_WINDOWS #elif defined(__unix__) || defined(__unix) #define WP_PLATFORM_UNIX #define WP_PLATFORM_POSIX #else #error "Unrecognised platform" #endif // Compiler #if defined(__clang__) #define WP_PLATFORM_CLANG #if defined(__GNUG__) #define WP_PLATFORM_CLANGPP #endif #define WP_PLATFORM_CLANG_MAJOR __clang_major__ #define WP_PLATFORM_CLANG_MINOR __clang_minor__ #define WP_PLATFORM_CLANG_PATCH __clang_patchlevel__ #elif defined(__GNUC__) || defined(__GNUG__) #define WP_PLATFORM_GCC #if defined(__GNUG__) #define WP_PLATFORM_GPP #endif #define WP_PLATFORM_GCC_MAJOR __GNUC__ #define WP_PLATFORM_GCC_MINOR __GNUC_MINOR__ #if defined(__GNUC_PATCHLEVEL__) #define WP_PLATFORM_GCC_PATCH __GNUC_PATCHLEVEL__ #endif #elif defined(_MSC_VER) #define WP_PLATFORM_MSVC #define WP_PLATFORM_MSVC_FULL_VERSION _MSC_FULL_VER #define WP_PLATFORM_MSVC_VERSION _MSC_VER #else #error "Unrecognised compiler" #endif // Language #ifdef __cplusplus #define WP_PLATFORM_CPP #define WP_PLATFORM_CPP_VERSION __cplusplus #define WP_PLATFORM_CPP98_VERSION 199711L #define WP_PLATFORM_CPP11_VERSION 201103L #define WP_PLATFORM_CPP14_VERSION 201402L #define WP_PLATFORM_CPP17_VERSION 201703L #define WP_PLATFORM_CPP20_VERSION 202002L #define WP_PLATFORM_CPP23_VERSION 202302L #if WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP98_VERSION #define WP_PLATFORM_CPP98 #elif WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP11_VERSION #define WP_PLATFORM_CPP11 #elif WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP14_VERSION #define WP_PLATFORM_CPP14 #elif WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP17_VERSION #define WP_PLATFORM_CPP17 #elif WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP20_VERSION #define WP_PLATFORM_CPP20 #elif WP_PLATFORM_CPP_VERSION == WP_PLATFORM_CPP23_VERSION #define WP_PLATFORM_CPP23 #else #error "Unrecognised C++ version" #endif #else #define WP_PLATFORM_C #if defined(__STDC_VERSION__) #define WP_PLATFORM_C_VERSION __STDC_VERSION__ #define WP_PLATFORM_C99_VERSION 199901L #define WP_PLATFORM_C11_VERSION 201112L #define WP_PLATFORM_C17_VERSION 201710L #define WP_PLATFORM_C23_VERSION 202311L #if WP_PLATFORM_C_VERSION == WP_PLATFORM_C99_VERSION #define WP_PLATFORM_C99 #elif WP_PLATFORM_C_VERSION == WP_PLATFORM_C11_VERSION #define WP_PLATFORM_C11 #elif WP_PLATFORM_C_VERSION == WP_PLATFORM_C17_VERSION #define WP_PLATFORM_C17 #elif WP_PLATFORM_C_VERSION == WP_PLATFORM_C23_VERSION #define WP_PLATFORM_C23 #else #error "Unrecognised C version" #endif #else #define WP_PLATFORM_C89 #endif #endif // !__cplusplus #endif // !PLATFORM_H