From b13274cd81793670bad4a2478674a9c09791199d Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 20 Apr 2025 18:27:57 +0100 Subject: [PATCH] Add compiler detection macros --- src/common/platform/platform.h | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/common/platform/platform.h b/src/common/platform/platform.h index 86221b2..c99059b 100644 --- a/src/common/platform/platform.h +++ b/src/common/platform/platform.h @@ -58,4 +58,40 @@ #error "Unrecognised platform" #endif +#ifdef __cplusplus + #define WAPP_PLATFORM_CPP + #if __cplusplus == 199711L + #define WAPP_PLATFORM_CPP98 + #elif __cplusplus == 201103L + #define WAPP_PLATFORM_CPP11 + #elif __cplusplus == 201402L + #define WAPP_PLATFORM_CPP14 + #elif __cplusplus == 201703L + #define WAPP_PLATFORM_CPP17 + #elif __cplusplus == 202002L + #define WAPP_PLATFORM_CPP20 + #elif __cplusplus == 202302L + #define WAPP_PLATFORM_CPP23 + #else + #error "Unrecognised C++ version" + #endif +#else + #define WAPP_PLATFORM_C + #if defined(__STDC_VERSION__) + #if __STDC_VERSION__ == 199901L + #define WAPP_PLATFORM_C99 + #elif __STDC_VERSION__ == 201112L + #define WAPP_PLATFORM_C11 + #elif __STDC_VERSION__ == 201710L + #define WAPP_PLATFORM_C17 + #elif __STDC_VERSION__ == 202311L + #define WAPP_PLATFORM_C23 + #else + #error "Unrecognised C version" + #endif + #else + #define WAPP_PLATFORM_C89 + #endif +#endif // !__cplusplus + #endif // !PLATFORM_H