diff --git a/Modules/Core/Common/src/itkNumericTraits.cxx b/Modules/Core/Common/src/itkNumericTraits.cxx index 8fbaf9c5490..69c48df8c94 100644 --- a/Modules/Core/Common/src/itkNumericTraits.cxx +++ b/Modules/Core/Common/src/itkNumericTraits.cxx @@ -15,6 +15,13 @@ * limitations under the License. * *=========================================================================*/ + +#if !defined(ITK_LEGACY_REMOVE) +// Suppress MSVC warnings from VS2022, saying: "warning C4996: 'std::complex::complex': warning STL4037: The effect +// of instantiating the template std::complex for any type other than float, double, or long double is unspecified." +# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING +#endif + #include "itkNumericTraits.h" namespace itk @@ -72,8 +79,6 @@ constexpr long double NumericTraits::Zero; constexpr long double NumericTraits::One; #if !defined(ITK_LEGACY_REMOVE) -// Supress MSVC warnings -# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING template <> const std::complex NumericTraits>::Zero = std::complex(0, 0); template <> diff --git a/Modules/Core/Common/test/itkMathTest.cxx b/Modules/Core/Common/test/itkMathTest.cxx index 6bb6c3214c7..eee51abc4f1 100644 --- a/Modules/Core/Common/test/itkMathTest.cxx +++ b/Modules/Core/Common/test/itkMathTest.cxx @@ -16,6 +16,12 @@ * *=========================================================================*/ +#if !defined(ITK_LEGACY_REMOVE) +// Suppress MSVC warnings from VS2022, saying: "warning C4996: 'std::complex::complex': warning STL4037: The effect +// of instantiating the template std::complex for any type other than float, double, or long double is unspecified." +# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING +#endif + #include "itkMath.h" #include "itkIntTypes.h" #include "itkStdStreamStateSave.h" @@ -25,11 +31,6 @@ #include #include // For is_same. -#if !defined(ITK_LEGACY_REMOVE) -// Supress MSVC warnings -# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING -#endif - constexpr auto maxUnsignedValue = std::numeric_limits::max(); using itk::Math::UnsignedPower; diff --git a/Modules/Core/Common/test/itkNumericTraitsTest.cxx b/Modules/Core/Common/test/itkNumericTraitsTest.cxx index f2c7831c2b3..b47fb22a6e2 100644 --- a/Modules/Core/Common/test/itkNumericTraitsTest.cxx +++ b/Modules/Core/Common/test/itkNumericTraitsTest.cxx @@ -16,6 +16,12 @@ * *=========================================================================*/ +#if !defined(ITK_LEGACY_REMOVE) +// Suppress MSVC warnings from VS2022, saying: "warning C4996: 'std::complex::complex': warning STL4037: The effect +// of instantiating the template std::complex for any type other than float, double, or long double is unspecified." +# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING +#endif + #include #include @@ -36,11 +42,6 @@ #include "itkNumericTraitsVariableLengthVectorPixel.h" #include "itkTestingMacros.h" -#if !defined(ITK_LEGACY_REMOVE) -// Supress MSVC warnings -# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING -#endif - namespace {