Skip to content

Commit cd0ff94

Browse files
N-Dekkerdzenanz
authored andcommitted
COMP: Place #define _SILENCE_..._DEPRECATION_WARNING before #include
Moved each `_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING` macro definition upward, placing it before the very first `#include` statement. Fixes Visual C++ 2022 warnings like: > warning C4996: 'std::complex<char>::complex': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. Follow-up to pull request #3897 commit 3a9c762 "COMP: Supress warning in MSVC for non-float complex"
1 parent bdc5234 commit cd0ff94

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

Modules/Core/Common/src/itkNumericTraits.cxx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
* limitations under the License.
1616
*
1717
*=========================================================================*/
18+
19+
#if !defined(ITK_LEGACY_REMOVE)
20+
// Suppress MSVC warnings from VS2022, saying: "warning C4996: 'std::complex<T>::complex': warning STL4037: The effect
21+
// of instantiating the template std::complex for any type other than float, double, or long double is unspecified."
22+
# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
23+
#endif
24+
1825
#include "itkNumericTraits.h"
1926

2027
namespace itk
@@ -72,8 +79,6 @@ constexpr long double NumericTraits<long double>::Zero;
7279
constexpr long double NumericTraits<long double>::One;
7380

7481
#if !defined(ITK_LEGACY_REMOVE)
75-
// Supress MSVC warnings
76-
# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
7782
template <>
7883
const std::complex<char> NumericTraits<std::complex<char>>::Zero = std::complex<char>(0, 0);
7984
template <>

Modules/Core/Common/test/itkMathTest.cxx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
*
1717
*=========================================================================*/
1818

19+
#if !defined(ITK_LEGACY_REMOVE)
20+
// Suppress MSVC warnings from VS2022, saying: "warning C4996: 'std::complex<T>::complex': warning STL4037: The effect
21+
// of instantiating the template std::complex for any type other than float, double, or long double is unspecified."
22+
# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
23+
#endif
24+
1925
#include "itkMath.h"
2026
#include "itkIntTypes.h"
2127
#include "itkStdStreamStateSave.h"
@@ -25,11 +31,6 @@
2531
#include <limits>
2632
#include <type_traits> // For is_same.
2733

28-
#if !defined(ITK_LEGACY_REMOVE)
29-
// Supress MSVC warnings
30-
# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
31-
#endif
32-
3334
constexpr auto maxUnsignedValue = std::numeric_limits<uintmax_t>::max();
3435

3536
using itk::Math::UnsignedPower;

Modules/Core/Common/test/itkNumericTraitsTest.cxx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
*
1717
*=========================================================================*/
1818

19+
#if !defined(ITK_LEGACY_REMOVE)
20+
// Suppress MSVC warnings from VS2022, saying: "warning C4996: 'std::complex<T>::complex': warning STL4037: The effect
21+
// of instantiating the template std::complex for any type other than float, double, or long double is unspecified."
22+
# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
23+
#endif
24+
1925
#include <iostream>
2026
#include <cstddef>
2127

@@ -36,11 +42,6 @@
3642
#include "itkNumericTraitsVariableLengthVectorPixel.h"
3743
#include "itkTestingMacros.h"
3844

39-
#if !defined(ITK_LEGACY_REMOVE)
40-
// Supress MSVC warnings
41-
# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
42-
#endif
43-
4445
namespace
4546
{
4647

0 commit comments

Comments
 (0)