Add compiler detection macros

This commit is contained in:
2026-08-30 00:10:16 +01:00
parent f599b5f425
commit a51686c8f0
+34
View File
@@ -3,6 +3,7 @@
#ifndef PLATFORM_H #ifndef PLATFORM_H
#define PLATFORM_H #define PLATFORM_H
// Operating system
#if defined(__ANDROID__) #if defined(__ANDROID__)
#define WP_PLATFORM_ANDROID #define WP_PLATFORM_ANDROID
#define WP_PLATFORM_POSIX #define WP_PLATFORM_POSIX
@@ -60,6 +61,39 @@
#error "Unrecognised platform" #error "Unrecognised platform"
#endif #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 #ifdef __cplusplus
#define WP_PLATFORM_CPP #define WP_PLATFORM_CPP
#define WP_PLATFORM_CPP_VERSION __cplusplus #define WP_PLATFORM_CPP_VERSION __cplusplus