From 901e8ba8c7eda74433caefa9e4fcedba3cefa118 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Mon, 3 Jul 2023 11:16:44 +0200 Subject: [PATCH] Fix preprocessor warnings about undefined _MSVC_LANG Stricter compiler/settings, such as found during a build on FreeBSD with clang 14, issue warnings of the kind below. /usr/local/include/exiv2/value.hpp:1272:31: warning: '_MSVC_LANG' is not defined, evaluates to 0 [-Wundef] Fix: Guard use of _MSVC_LANG by a check. Personally, I found that MSVC has several feature-specific checks in predefined macros which might allow for one standards-based check that matches GCC/clang/MSVC rather than the split check for C++ standard and MSVC language version settings. See https://en.cppreference.com/w/cpp/feature_test I am not building Exiv2 on MSVC, so I cannot test/suggest anything here. --- include/exiv2/slice.hpp | 8 ++++---- include/exiv2/value.hpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/exiv2/slice.hpp b/include/exiv2/slice.hpp index be064aecc0..9842ebcb0c 100644 --- a/include/exiv2/slice.hpp +++ b/include/exiv2/slice.hpp @@ -255,7 +255,7 @@ struct ContainerStorage { using iterator = typename container::iterator; using const_iterator = typename container::const_iterator; -#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L +#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) using value_type = std::remove_cv_t; #else using value_type = typename std::remove_cv::type; @@ -320,7 +320,7 @@ struct ContainerStorage { */ template struct PtrSliceStorage { -#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L +#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) using value_type = std::remove_cv_t>; #else using value_type = typename std::remove_cv::type>::type; @@ -423,7 +423,7 @@ struct Slice : public Internal::MutableSliceBase= 201402L || _MSVC_LANG >= 201402L +#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) using value_type = std::remove_cv_t; #else using value_type = typename std::remove_cv::type; @@ -460,7 +460,7 @@ struct Slice : public Internal::ConstSliceBase= 201402L || _MSVC_LANG >= 201402L +#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) using value_type = std::remove_cv_t; #else using value_type = typename std::remove_cv::type; diff --git a/include/exiv2/value.hpp b/include/exiv2/value.hpp index ed9edf622c..0c55d822e0 100644 --- a/include/exiv2/value.hpp +++ b/include/exiv2/value.hpp @@ -1254,7 +1254,7 @@ class ValueType : public Value { } else if (std::is_signed::value) { #endif // conversion is from unsigned to signed -#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L +#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) const auto imax = static_cast>(std::numeric_limits::max()); #else const auto imax = static_cast::type>(std::numeric_limits::max()); @@ -1269,7 +1269,7 @@ class ValueType : public Value { return 0; } // Inputs are not negative so convert them to unsigned. -#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L +#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) const auto a_u = static_cast>(a); const auto b_u = static_cast>(b); #else