Add C and CPP version macros

This commit is contained in:
Abdelrahman Said 2025-04-20 19:39:16 +01:00
parent 037b0fe698
commit 7605eb4e57

View File

@ -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"