From 56d04d2c5df59b91e316f5aabfe9d9f43d557044 Mon Sep 17 00:00:00 2001 From: HoseynHeydari Date: Mon, 18 Apr 2022 01:48:32 +0430 Subject: [PATCH] Move compiler detection header beffore using CATCH_COMPILER_CLANG macro. (see #2094) --- src/catch2/internal/catch_compiler_capabilities.hpp | 2 +- src/catch2/internal/catch_compiler_detections.hpp | 2 +- src/catch2/internal/catch_config_uncaught_exceptions.hpp | 2 +- src/catch2/internal/catch_container_nonmembers.hpp | 2 +- src/catch2/internal/catch_debugger.cpp | 2 +- src/catch2/internal/catch_debugger.hpp | 2 +- src/catch2/internal/catch_decomposer.hpp | 4 ++-- src/catch2/internal/catch_output_redirect.cpp | 8 ++++---- src/catch2/internal/catch_output_redirect.hpp | 2 +- src/catch2/internal/catch_platform.hpp | 2 +- src/catch2/internal/catch_random_number_generator.cpp | 4 ++-- src/catch2/internal/catch_test_spec_parser.hpp | 3 ++- 12 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index 2f9ee339..67611863 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -156,7 +156,7 @@ //////////////////////////////////////////////////////////////////////////////// // Visual C++ -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) diff --git a/src/catch2/internal/catch_compiler_detections.hpp b/src/catch2/internal/catch_compiler_detections.hpp index f30bc446..717f1c36 100644 --- a/src/catch2/internal/catch_compiler_detections.hpp +++ b/src/catch2/internal/catch_compiler_detections.hpp @@ -16,7 +16,7 @@ #endif #if defined(_MSC_VER) && !defined(__clang__) -#define CATCH_COMPILER_MSC +#define CATCH_COMPILER_MSVC #endif #if defined(__MINGW32__) diff --git a/src/catch2/internal/catch_config_uncaught_exceptions.hpp b/src/catch2/internal/catch_config_uncaught_exceptions.hpp index d3dc37a1..2f623246 100644 --- a/src/catch2/internal/catch_config_uncaught_exceptions.hpp +++ b/src/catch2/internal/catch_config_uncaught_exceptions.hpp @@ -19,7 +19,7 @@ #include -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) # if _MSC_VER >= 1900 // Visual Studio 2015 or newer # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS # endif diff --git a/src/catch2/internal/catch_container_nonmembers.hpp b/src/catch2/internal/catch_container_nonmembers.hpp index 7e9f8c12..6af00e0d 100644 --- a/src/catch2/internal/catch_container_nonmembers.hpp +++ b/src/catch2/internal/catch_container_nonmembers.hpp @@ -18,7 +18,7 @@ // for C++14 or C++ libraries with incomplete support. // We also have to handle that MSVC std lib will happily provide these // under older standards. -#if defined(CATCH_CPP17_OR_GREATER) || defined(CATCH_COMPILER_MSC) +#if defined(CATCH_CPP17_OR_GREATER) || defined(CATCH_COMPILER_MSVC) // We are already using this header either way, so there shouldn't // be much additional overhead in including it to get the feature diff --git a/src/catch2/internal/catch_debugger.cpp b/src/catch2/internal/catch_debugger.cpp index f55adbce..9934dc08 100644 --- a/src/catch2/internal/catch_debugger.cpp +++ b/src/catch2/internal/catch_debugger.cpp @@ -101,7 +101,7 @@ return false; } } // namespace Catch -#elif defined(CATCH_COMPILER_MSC) +#elif defined(CATCH_COMPILER_MSVC) extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); namespace Catch { bool isDebuggerActive() { diff --git a/src/catch2/internal/catch_debugger.hpp b/src/catch2/internal/catch_debugger.hpp index e89756f0..d880bc7b 100644 --- a/src/catch2/internal/catch_debugger.hpp +++ b/src/catch2/internal/catch_debugger.hpp @@ -47,7 +47,7 @@ namespace Catch { #define CATCH_TRAP() raise(SIGTRAP) #endif -#elif defined(CATCH_COMPILER_MSC) +#elif defined(CATCH_COMPILER_MSVC) #define CATCH_TRAP() __debugbreak() #elif defined(CATCH_COMPILER_MINGW32) extern "C" __declspec(dllimport) void __stdcall DebugBreak(); diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp index 73772ec6..7546322c 100644 --- a/src/catch2/internal/catch_decomposer.hpp +++ b/src/catch2/internal/catch_decomposer.hpp @@ -15,7 +15,7 @@ #include -#ifdef CATCH_COMPILER_MSC +#ifdef CATCH_COMPILER_MSVC #pragma warning(push) #pragma warning(disable:4389) // '==' : signed/unsigned mismatch #pragma warning(disable:4018) // more "signed/unsigned mismatch" @@ -257,7 +257,7 @@ namespace Catch { } // end namespace Catch -#ifdef CATCH_COMPILER_MSC +#ifdef CATCH_COMPILER_MSVC #pragma warning(pop) #endif #ifdef CATCH_COMPILER_CLANG diff --git a/src/catch2/internal/catch_output_redirect.cpp b/src/catch2/internal/catch_output_redirect.cpp index 6d1569a6..2ea69206 100644 --- a/src/catch2/internal/catch_output_redirect.cpp +++ b/src/catch2/internal/catch_output_redirect.cpp @@ -16,7 +16,7 @@ #include #if defined(CATCH_CONFIG_NEW_CAPTURE) - #if defined(CATCH_COMPILER_MSC) + #if defined(CATCH_COMPILER_MSVC) #include //_dup and _dup2 #define dup _dup #define dup2 _dup2 @@ -62,7 +62,7 @@ namespace Catch { #if defined(CATCH_CONFIG_NEW_CAPTURE) -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) TempFile::TempFile() { if (tmpnam_s(m_buffer)) { CATCH_RUNTIME_ERROR("Could not get a temp filename"); @@ -90,7 +90,7 @@ namespace Catch { std::fclose(m_file); // We manually create the file on Windows only, on Linux // it will be autodeleted -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) std::remove(m_buffer); #endif } @@ -140,7 +140,7 @@ namespace Catch { } // namespace Catch #if defined(CATCH_CONFIG_NEW_CAPTURE) - #if defined(CATCH_COMPILER_MSC) + #if defined(CATCH_COMPILER_MSVC) #undef dup #undef dup2 #undef fileno diff --git a/src/catch2/internal/catch_output_redirect.hpp b/src/catch2/internal/catch_output_redirect.hpp index 2eaa0135..2654e5eb 100644 --- a/src/catch2/internal/catch_output_redirect.hpp +++ b/src/catch2/internal/catch_output_redirect.hpp @@ -86,7 +86,7 @@ namespace Catch { private: std::FILE* m_file = nullptr; - #if defined(CATCH_COMPILER_MSC) + #if defined(CATCH_COMPILER_MSVC) char m_buffer[L_tmpnam] = { 0 }; #endif }; diff --git a/src/catch2/internal/catch_platform.hpp b/src/catch2/internal/catch_platform.hpp index ba723765..fe56141e 100644 --- a/src/catch2/internal/catch_platform.hpp +++ b/src/catch2/internal/catch_platform.hpp @@ -24,7 +24,7 @@ #elif defined(linux) || defined(__linux) || defined(__linux__) # define CATCH_PLATFORM_LINUX -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(CATCH_COMPILER_MSC) || defined(CATCH_COMPILER_MINGW32) +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(CATCH_COMPILER_MSVC) || defined(CATCH_COMPILER_MINGW32) # define CATCH_PLATFORM_WINDOWS #endif diff --git a/src/catch2/internal/catch_random_number_generator.cpp b/src/catch2/internal/catch_random_number_generator.cpp index 75d91e38..0fa71fb0 100644 --- a/src/catch2/internal/catch_random_number_generator.cpp +++ b/src/catch2/internal/catch_random_number_generator.cpp @@ -13,7 +13,7 @@ namespace Catch { namespace { -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) #pragma warning(push) #pragma warning(disable:4146) // we negate uint32 during the rotate #endif @@ -24,7 +24,7 @@ namespace { return (val >> count) | (val << (-count & mask)); } -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) #pragma warning(pop) #endif diff --git a/src/catch2/internal/catch_test_spec_parser.hpp b/src/catch2/internal/catch_test_spec_parser.hpp index b4a52f85..d7f235c3 100644 --- a/src/catch2/internal/catch_test_spec_parser.hpp +++ b/src/catch2/internal/catch_test_spec_parser.hpp @@ -8,12 +8,13 @@ #ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED #define CATCH_TEST_SPEC_PARSER_HPP_INCLUDED +#include + #ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" #endif -#include #include #include