From b31b4abbafcc9187245c5c392490fa5867bde94c Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 3 Jan 2023 21:41:31 -0800 Subject: [PATCH] fix __cplusplus check for MSVC Because of an MSVC bug, __cplusplus is always 199711L. Use _MSVC_LANG which gets set properly. Signed-off-by: Rosen Penev --- include/exiv2/value.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/exiv2/value.hpp b/include/exiv2/value.hpp index 5f39cce4..dd82be4f 100644 --- a/include/exiv2/value.hpp +++ b/include/exiv2/value.hpp @@ -1270,7 +1270,7 @@ class ValueType : public Value { } // Check for integer overflow. -#if __cplusplus >= 201703L +#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L if constexpr (std::is_signed_v == std::is_signed_v) { #else if (std::is_signed::value == std::is_signed::value) { @@ -1281,13 +1281,13 @@ class ValueType : public Value { if (imax < b || a < imin || imax < a) { return 0; } -#if __cplusplus >= 201703L +#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L } else if constexpr (std::is_signed_v) { #else } else if (std::is_signed::value) { #endif // conversion is from unsigned to signed -#if __cplusplus >= 201402L +#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L const auto imax = static_cast>(std::numeric_limits::max()); #else const auto imax = static_cast::type>(std::numeric_limits::max()); @@ -1302,7 +1302,7 @@ class ValueType : public Value { return 0; } // Inputs are not negative so convert them to unsigned. -#if __cplusplus >= 201402L +#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L const auto a_u = static_cast>(a); const auto b_u = static_cast>(b); #else