From 1833c91b5af452928a086b17e5b29e8450fbbb17 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 25 Nov 2021 19:30:00 +0200 Subject: [PATCH 1/2] Make MSVC use [[nodiscard]] Uniformly detect attributes for __cplusplus and _MSVC_LANG --- include/fmt/core.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 8ff91a1526f4..d47750576313 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -18,7 +18,7 @@ // The fmt library version in the form major * 10000 + minor * 100 + patch. #define FMT_VERSION 80001 -#if defined(__clang__) && !defined(__ibmxl__) +#if defined (__clang__ ) && !defined(__ibmxl__) # define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) #else # define FMT_CLANG_VERSION 0 @@ -82,11 +82,17 @@ # define FMT_HAS_CPP_ATTRIBUTE(x) 0 #endif +#ifdef _MSVC_LANG +# define FMT_CPLUSPLUS _MSVC_LANG +#else +# define FMT_CPLUSPLUS __cplusplus +#endif + #define FMT_HAS_CPP14_ATTRIBUTE(attribute) \ - (__cplusplus >= 201402L && FMT_HAS_CPP_ATTRIBUTE(attribute)) + (FMT_CPLUSPLUS >= 201402L && FMT_HAS_CPP_ATTRIBUTE(attribute)) #define FMT_HAS_CPP17_ATTRIBUTE(attribute) \ - (__cplusplus >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute)) + (FMT_CPLUSPLUS >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute)) // Check if relaxed C++14 constexpr is supported. // GCC doesn't allow throw in constexpr until version 6 (bug 67371). @@ -180,8 +186,7 @@ # else # define FMT_FALLTHROUGH # endif -#elif FMT_HAS_CPP17_ATTRIBUTE(fallthrough) || \ - (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) +#elif FMT_HAS_CPP17_ATTRIBUTE(fallthrough) # define FMT_FALLTHROUGH [[fallthrough]] #else # define FMT_FALLTHROUGH From 6a13275f9ea91ec1533cf7c97080e5475eeb5c68 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 25 Nov 2021 19:53:49 +0200 Subject: [PATCH 2/2] It was not me! --- include/fmt/core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index d47750576313..a006b5bb46a8 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -18,7 +18,7 @@ // The fmt library version in the form major * 10000 + minor * 100 + patch. #define FMT_VERSION 80001 -#if defined (__clang__ ) && !defined(__ibmxl__) +#if defined(__clang__) && !defined(__ibmxl__) # define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) #else # define FMT_CLANG_VERSION 0