From 706d4726c6977aff4c953ba372786686d73a3b89 Mon Sep 17 00:00:00 2001 From: Andy Brauninger <43097655+abrauninger@users.noreply.github.com> Date: Wed, 30 Nov 2022 11:57:10 -0800 Subject: [PATCH 1/2] Use the new MSVC preprocessor --- Release/CMakeLists.txt | 4 ++++ Release/tests/common/UnitTestpp/src/CheckMacros.h | 4 ++-- Release/tests/common/UnitTestpp/src/TestMacros.h | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index b8f3809dbc..ad752ce390 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -192,6 +192,10 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") if (NOT (MSVC_VERSION LESS 1920)) add_compile_options(/permissive-) endif() + + if (NOT (MSVC_VERSION LESS 1926)) + add_compile_options(/Zc:preprocessor) + endif() endif() else() message("-- Unknown compiler, success is doubtful.") diff --git a/Release/tests/common/UnitTestpp/src/CheckMacros.h b/Release/tests/common/UnitTestpp/src/CheckMacros.h index 43a9cccaf8..87c14af22f 100644 --- a/Release/tests/common/UnitTestpp/src/CheckMacros.h +++ b/Release/tests/common/UnitTestpp/src/CheckMacros.h @@ -94,7 +94,7 @@ #error UnitTest++ redefines VERIFY_IS_NULL #endif -#ifdef WIN32 +#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) #define VERIFY_IS_TRUE(expression, ...) CHECK_EQUAL(true, expression, __VA_ARGS__) #define VERIFY_IS_FALSE(expression, ...) CHECK_EQUAL(false, expression, __VA_ARGS__) #define VERIFY_ARE_NOT_EQUAL(expected, actual, ...) CHECK_NOT_EQUAL(expected, actual, __VA_ARGS__) @@ -118,7 +118,7 @@ UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \ UNITTEST_MULTILINE_MACRO_END -#ifdef WIN32 +#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) #define CHECK_EQUAL(expected, actual, ...) \ do \ diff --git a/Release/tests/common/UnitTestpp/src/TestMacros.h b/Release/tests/common/UnitTestpp/src/TestMacros.h index a73b3f1e07..8a8342e2d6 100644 --- a/Release/tests/common/UnitTestpp/src/TestMacros.h +++ b/Release/tests/common/UnitTestpp/src/TestMacros.h @@ -93,7 +93,7 @@ extern "C" _DLL_EXPORT TestList& __cdecl GetTestList(); } \ namespace Suite##Name -#ifdef _WIN32 +#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) #define TEST_EX(Name, List, ...) \ class Test##Name : public UnitTest::Test \ { \ @@ -124,13 +124,13 @@ extern "C" _DLL_EXPORT TestList& __cdecl GetTestList(); void Test##Name::RunImpl() const #endif -#ifdef _WIN32 +#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) #define TEST(Name, ...) TEST_EX(Name, UnitTest::GetTestList(), __VA_ARGS__) #else #define TEST(Name, ...) TEST_EX(Name, UnitTest::GetTestList(), ##__VA_ARGS__) #endif -#ifdef _WIN32 +#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) #define TEST_FIXTURE_EX(Fixture, Name, List, ...) \ class Fixture##Name##Helper : public Fixture \ { \ @@ -242,7 +242,7 @@ extern "C" _DLL_EXPORT TestList& __cdecl GetTestList(); void Fixture##Name##Helper::RunImpl() #endif -#ifdef _WIN32 +#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) #define TEST_FIXTURE(Fixture, Name, ...) TEST_FIXTURE_EX(Fixture, Name, UnitTest::GetTestList(), __VA_ARGS__) #else #define TEST_FIXTURE(Fixture, Name, ...) TEST_FIXTURE_EX(Fixture, Name, UnitTest::GetTestList(), ##__VA_ARGS__) From 02aee02c0eb4a2eb8b94ad73a75b4cb6f9ffd55b Mon Sep 17 00:00:00 2001 From: Andy Brauninger <43097655+abrauninger@users.noreply.github.com> Date: Wed, 30 Nov 2022 12:40:50 -0800 Subject: [PATCH 2/2] Use _MSVC_TRADITIONAL instead of _MSC_VER --- Release/tests/common/UnitTestpp/src/CheckMacros.h | 4 ++-- Release/tests/common/UnitTestpp/src/TestMacros.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Release/tests/common/UnitTestpp/src/CheckMacros.h b/Release/tests/common/UnitTestpp/src/CheckMacros.h index 87c14af22f..a1fd3e2a63 100644 --- a/Release/tests/common/UnitTestpp/src/CheckMacros.h +++ b/Release/tests/common/UnitTestpp/src/CheckMacros.h @@ -94,7 +94,7 @@ #error UnitTest++ redefines VERIFY_IS_NULL #endif -#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) +#if !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL #define VERIFY_IS_TRUE(expression, ...) CHECK_EQUAL(true, expression, __VA_ARGS__) #define VERIFY_IS_FALSE(expression, ...) CHECK_EQUAL(false, expression, __VA_ARGS__) #define VERIFY_ARE_NOT_EQUAL(expected, actual, ...) CHECK_NOT_EQUAL(expected, actual, __VA_ARGS__) @@ -118,7 +118,7 @@ UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \ UNITTEST_MULTILINE_MACRO_END -#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) +#if !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL #define CHECK_EQUAL(expected, actual, ...) \ do \ diff --git a/Release/tests/common/UnitTestpp/src/TestMacros.h b/Release/tests/common/UnitTestpp/src/TestMacros.h index 8a8342e2d6..c25879b11a 100644 --- a/Release/tests/common/UnitTestpp/src/TestMacros.h +++ b/Release/tests/common/UnitTestpp/src/TestMacros.h @@ -93,7 +93,7 @@ extern "C" _DLL_EXPORT TestList& __cdecl GetTestList(); } \ namespace Suite##Name -#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) +#if !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL #define TEST_EX(Name, List, ...) \ class Test##Name : public UnitTest::Test \ { \ @@ -124,13 +124,13 @@ extern "C" _DLL_EXPORT TestList& __cdecl GetTestList(); void Test##Name::RunImpl() const #endif -#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) +#if !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL #define TEST(Name, ...) TEST_EX(Name, UnitTest::GetTestList(), __VA_ARGS__) #else #define TEST(Name, ...) TEST_EX(Name, UnitTest::GetTestList(), ##__VA_ARGS__) #endif -#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) +#if !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL #define TEST_FIXTURE_EX(Fixture, Name, List, ...) \ class Fixture##Name##Helper : public Fixture \ { \ @@ -242,7 +242,7 @@ extern "C" _DLL_EXPORT TestList& __cdecl GetTestList(); void Fixture##Name##Helper::RunImpl() #endif -#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1926) +#if !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL #define TEST_FIXTURE(Fixture, Name, ...) TEST_FIXTURE_EX(Fixture, Name, UnitTest::GetTestList(), __VA_ARGS__) #else #define TEST_FIXTURE(Fixture, Name, ...) TEST_FIXTURE_EX(Fixture, Name, UnitTest::GetTestList(), ##__VA_ARGS__)