From 7605eb4e57dca21f3e07a42470c681e5dacdb91a Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 20 Apr 2025 19:39:16 +0100 Subject: [PATCH] Add C and CPP version macros --- src/common/platform/platform.h | 35 ++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/common/platform/platform.h b/src/common/platform/platform.h index c99059b..83c442e 100644 --- a/src/common/platform/platform.h +++ b/src/common/platform/platform.h @@ -60,31 +60,46 @@ #ifdef __cplusplus #define WAPP_PLATFORM_CPP - #if __cplusplus == 199711L + #define WAPP_PLATFORM_CPP_VERSION __cplusplus + #define WAPP_PLATFORM_CPP98_VERSION 199711L + #define WAPP_PLATFORM_CPP11_VERSION 201103L + #define WAPP_PLATFORM_CPP14_VERSION 201402L + #define WAPP_PLATFORM_CPP17_VERSION 201703L + #define WAPP_PLATFORM_CPP20_VERSION 202002L + #define WAPP_PLATFORM_CPP23_VERSION 202302L + + #if __cplusplus == WAPP_PLATFORM_CPP98_VERSION #define WAPP_PLATFORM_CPP98 - #elif __cplusplus == 201103L + #elif __cplusplus == WAPP_PLATFORM_CPP11_VERSION #define WAPP_PLATFORM_CPP11 - #elif __cplusplus == 201402L + #elif __cplusplus == WAPP_PLATFORM_CPP14_VERSION #define WAPP_PLATFORM_CPP14 - #elif __cplusplus == 201703L + #elif __cplusplus == WAPP_PLATFORM_CPP17_VERSION #define WAPP_PLATFORM_CPP17 - #elif __cplusplus == 202002L + #elif __cplusplus == WAPP_PLATFORM_CPP20_VERSION #define WAPP_PLATFORM_CPP20 - #elif __cplusplus == 202302L + #elif __cplusplus == WAPP_PLATFORM_CPP23_VERSION #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_C_VERSION __STDC_VERSION__ + #define WAPP_PLATFORM_C99_VERSION 199901L + #define WAPP_PLATFORM_C11_VERSION 201112L + #define WAPP_PLATFORM_C17_VERSION 201710L + #define WAPP_PLATFORM_C23_VERSION 202311L + + #if __STDC_VERSION__ == WAPP_PLATFORM_C99_VERSION #define WAPP_PLATFORM_C99 - #elif __STDC_VERSION__ == 201112L + #elif __STDC_VERSION__ == WAPP_PLATFORM_C11_VERSION #define WAPP_PLATFORM_C11 - #elif __STDC_VERSION__ == 201710L + #elif __STDC_VERSION__ == WAPP_PLATFORM_C17_VERSION #define WAPP_PLATFORM_C17 - #elif __STDC_VERSION__ == 202311L + #elif __STDC_VERSION__ == WAPP_PLATFORM_C23_VERSION #define WAPP_PLATFORM_C23 #else #error "Unrecognised C version"