From f87293848cebf30f0a302e9a25e260a3c0ffa2bb Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 19 May 2024 14:21:12 -0400 Subject: [PATCH] fix: improve C++ version detection macros --- includes/rtm/impl/detect_cpp_version.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/includes/rtm/impl/detect_cpp_version.h b/includes/rtm/impl/detect_cpp_version.h index ea57de81..1d752c02 100644 --- a/includes/rtm/impl/detect_cpp_version.h +++ b/includes/rtm/impl/detect_cpp_version.h @@ -27,14 +27,16 @@ ////////////////////////////////////////////////////////////////////////// // Macros to identify individual C++ versions ////////////////////////////////////////////////////////////////////////// -#if defined(__cplusplus) && __cplusplus >= 202002L - #define RTM_CPP_VERSION __cplusplus +#if defined(_MSVC_LANG) + // Test MSVC first since it used to define __cplusplus to some old version by default + + #define RTM_CPP_VERSION _MSVC_LANG #define RTM_CPP_VERSION_14 201402L #define RTM_CPP_VERSION_17 201703L #define RTM_CPP_VERSION_20 202002L -#elif defined(_MSVC_LANG) && _MSVC_LANG >= 202002L - #define RTM_CPP_VERSION _MSVC_LANG +#elif defined(__cplusplus) + #define RTM_CPP_VERSION __cplusplus #define RTM_CPP_VERSION_14 201402L #define RTM_CPP_VERSION_17 201703L