Added
Link Here
|
1 |
From aaa876159ada768ba0fb2d44b4eaaf23b3b2ed98 Mon Sep 17 00:00:00 2001 |
2 |
From: Matthias Andree <matthias.andree@gmx.de> |
3 |
Date: Mon, 3 Jul 2023 11:16:44 +0200 |
4 |
Subject: [PATCH] Fix preprocessor warnings about undefined _MSVC_LANG |
5 |
|
6 |
Stricter compiler/settings, such as found during a build |
7 |
on FreeBSD with clang 14, issue warnings of the kind below. |
8 |
|
9 |
/usr/local/include/exiv2/value.hpp:1272:31: warning: '_MSVC_LANG' is not defined, evaluates to 0 [-Wundef] |
10 |
fixed-width font helps here-- ^ |
11 |
|
12 |
Fix: Guard use of _MSVC_LANG by a check. |
13 |
|
14 |
Personally, I found that MSVC has several feature-specific |
15 |
checks in predefined macros which might allow for one |
16 |
standards-based check that matches GCC/clang/MSVC rather than the |
17 |
split check for C++ standard and MSVC language version settings. |
18 |
|
19 |
See https://en.cppreference.com/w/cpp/feature_test |
20 |
|
21 |
I am not building Exiv2 on MSVC, so I cannot test/suggest |
22 |
anything here. |
23 |
--- include/exiv2/slice.hpp.orig 2023-05-08 16:01:13 UTC |
24 |
+++ include/exiv2/slice.hpp |
25 |
@@ -255,7 +255,7 @@ struct ContainerStorage { |
26 |
using iterator = typename container::iterator; |
27 |
using const_iterator = typename container::const_iterator; |
28 |
|
29 |
-#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L |
30 |
+#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) |
31 |
using value_type = std::remove_cv_t<typename container::value_type>; |
32 |
#else |
33 |
using value_type = typename std::remove_cv<typename container::value_type>::type; |
34 |
@@ -320,7 +320,7 @@ struct ContainerStorage { |
35 |
*/ |
36 |
template <typename storage_type> |
37 |
struct PtrSliceStorage { |
38 |
-#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L |
39 |
+#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) |
40 |
using value_type = std::remove_cv_t<std::remove_pointer_t<storage_type>>; |
41 |
#else |
42 |
using value_type = typename std::remove_cv<typename std::remove_pointer<storage_type>::type>::type; |
43 |
@@ -423,7 +423,7 @@ struct Slice : public Internal::MutableSliceBase<Inter |
44 |
using iterator = typename container::iterator; |
45 |
using const_iterator = typename container::const_iterator; |
46 |
|
47 |
-#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L |
48 |
+#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) |
49 |
using value_type = std::remove_cv_t<typename container::value_type>; |
50 |
#else |
51 |
using value_type = typename std::remove_cv<typename container::value_type>::type; |
52 |
@@ -460,7 +460,7 @@ struct Slice<const container> : public Internal::Const |
53 |
using iterator = typename container::iterator; |
54 |
using const_iterator = typename container::const_iterator; |
55 |
|
56 |
-#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L |
57 |
+#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) |
58 |
using value_type = std::remove_cv_t<typename container::value_type>; |
59 |
#else |
60 |
using value_type = typename std::remove_cv<typename container::value_type>::type; |
61 |
include/exiv2/slice.hpp | 8 ++++---- |
62 |
include/exiv2/value.hpp | 4 ++-- |
63 |
2 files changed, 6 insertions(+), 6 deletions(-) |
64 |
|
65 |
--- include/exiv2/value.hpp.orig 2023-05-08 16:01:13 UTC |
66 |
+++ include/exiv2/value.hpp |
67 |
@@ -1254,7 +1254,7 @@ class ValueType : public Value { |
68 |
} else if (std::is_signed<I>::value) { |
69 |
#endif |
70 |
// conversion is from unsigned to signed |
71 |
-#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L |
72 |
+#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) |
73 |
const auto imax = static_cast<std::make_unsigned_t<I>>(std::numeric_limits<I>::max()); |
74 |
#else |
75 |
const auto imax = static_cast<typename std::make_unsigned<I>::type>(std::numeric_limits<I>::max()); |
76 |
@@ -1269,7 +1269,7 @@ class ValueType : public Value { |
77 |
return 0; |
78 |
} |
79 |
// Inputs are not negative so convert them to unsigned. |
80 |
-#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L |
81 |
+#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)) |
82 |
const auto a_u = static_cast<std::make_unsigned_t<decltype(a)>>(a); |
83 |
const auto b_u = static_cast<std::make_unsigned_t<decltype(b)>>(b); |
84 |
#else |