Move compiler detection header beffore using

CATCH_COMPILER_CLANG macro. (see #2094)
This commit is contained in:
HoseynHeydari 2022-04-18 01:48:32 +04:30
parent e1827f7875
commit 56d04d2c5d
12 changed files with 18 additions and 17 deletions

View File

@ -156,7 +156,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Visual C++ // Visual C++
#if defined(CATCH_COMPILER_MSC) #if defined(CATCH_COMPILER_MSVC)
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) )
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) )

View File

@ -16,7 +16,7 @@
#endif #endif
#if defined(_MSC_VER) && !defined(__clang__) #if defined(_MSC_VER) && !defined(__clang__)
#define CATCH_COMPILER_MSC #define CATCH_COMPILER_MSVC
#endif #endif
#if defined(__MINGW32__) #if defined(__MINGW32__)

View File

@ -19,7 +19,7 @@
#include <catch2/internal/catch_compiler_detections.hpp> #include <catch2/internal/catch_compiler_detections.hpp>
#if defined(CATCH_COMPILER_MSC) #if defined(CATCH_COMPILER_MSVC)
# if _MSC_VER >= 1900 // Visual Studio 2015 or newer # if _MSC_VER >= 1900 // Visual Studio 2015 or newer
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
# endif # endif

View File

@ -18,7 +18,7 @@
// for C++14 or C++ libraries with incomplete support. // for C++14 or C++ libraries with incomplete support.
// We also have to handle that MSVC std lib will happily provide these // We also have to handle that MSVC std lib will happily provide these
// under older standards. // 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 // We are already using this header either way, so there shouldn't
// be much additional overhead in including it to get the feature // be much additional overhead in including it to get the feature

View File

@ -101,7 +101,7 @@
return false; return false;
} }
} // namespace Catch } // namespace Catch
#elif defined(CATCH_COMPILER_MSC) #elif defined(CATCH_COMPILER_MSVC)
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
namespace Catch { namespace Catch {
bool isDebuggerActive() { bool isDebuggerActive() {

View File

@ -47,7 +47,7 @@ namespace Catch {
#define CATCH_TRAP() raise(SIGTRAP) #define CATCH_TRAP() raise(SIGTRAP)
#endif #endif
#elif defined(CATCH_COMPILER_MSC) #elif defined(CATCH_COMPILER_MSVC)
#define CATCH_TRAP() __debugbreak() #define CATCH_TRAP() __debugbreak()
#elif defined(CATCH_COMPILER_MINGW32) #elif defined(CATCH_COMPILER_MINGW32)
extern "C" __declspec(dllimport) void __stdcall DebugBreak(); extern "C" __declspec(dllimport) void __stdcall DebugBreak();

View File

@ -15,7 +15,7 @@
#include <iosfwd> #include <iosfwd>
#ifdef CATCH_COMPILER_MSC #ifdef CATCH_COMPILER_MSVC
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4389) // '==' : signed/unsigned mismatch #pragma warning(disable:4389) // '==' : signed/unsigned mismatch
#pragma warning(disable:4018) // more "signed/unsigned mismatch" #pragma warning(disable:4018) // more "signed/unsigned mismatch"
@ -257,7 +257,7 @@ namespace Catch {
} // end namespace Catch } // end namespace Catch
#ifdef CATCH_COMPILER_MSC #ifdef CATCH_COMPILER_MSVC
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#ifdef CATCH_COMPILER_CLANG #ifdef CATCH_COMPILER_CLANG

View File

@ -16,7 +16,7 @@
#include <sstream> #include <sstream>
#if defined(CATCH_CONFIG_NEW_CAPTURE) #if defined(CATCH_CONFIG_NEW_CAPTURE)
#if defined(CATCH_COMPILER_MSC) #if defined(CATCH_COMPILER_MSVC)
#include <io.h> //_dup and _dup2 #include <io.h> //_dup and _dup2
#define dup _dup #define dup _dup
#define dup2 _dup2 #define dup2 _dup2
@ -62,7 +62,7 @@ namespace Catch {
#if defined(CATCH_CONFIG_NEW_CAPTURE) #if defined(CATCH_CONFIG_NEW_CAPTURE)
#if defined(CATCH_COMPILER_MSC) #if defined(CATCH_COMPILER_MSVC)
TempFile::TempFile() { TempFile::TempFile() {
if (tmpnam_s(m_buffer)) { if (tmpnam_s(m_buffer)) {
CATCH_RUNTIME_ERROR("Could not get a temp filename"); CATCH_RUNTIME_ERROR("Could not get a temp filename");
@ -90,7 +90,7 @@ namespace Catch {
std::fclose(m_file); std::fclose(m_file);
// We manually create the file on Windows only, on Linux // We manually create the file on Windows only, on Linux
// it will be autodeleted // it will be autodeleted
#if defined(CATCH_COMPILER_MSC) #if defined(CATCH_COMPILER_MSVC)
std::remove(m_buffer); std::remove(m_buffer);
#endif #endif
} }
@ -140,7 +140,7 @@ namespace Catch {
} // namespace Catch } // namespace Catch
#if defined(CATCH_CONFIG_NEW_CAPTURE) #if defined(CATCH_CONFIG_NEW_CAPTURE)
#if defined(CATCH_COMPILER_MSC) #if defined(CATCH_COMPILER_MSVC)
#undef dup #undef dup
#undef dup2 #undef dup2
#undef fileno #undef fileno

View File

@ -86,7 +86,7 @@ namespace Catch {
private: private:
std::FILE* m_file = nullptr; std::FILE* m_file = nullptr;
#if defined(CATCH_COMPILER_MSC) #if defined(CATCH_COMPILER_MSVC)
char m_buffer[L_tmpnam] = { 0 }; char m_buffer[L_tmpnam] = { 0 };
#endif #endif
}; };

View File

@ -24,7 +24,7 @@
#elif defined(linux) || defined(__linux) || defined(__linux__) #elif defined(linux) || defined(__linux) || defined(__linux__)
# define CATCH_PLATFORM_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 # define CATCH_PLATFORM_WINDOWS
#endif #endif

View File

@ -13,7 +13,7 @@ namespace Catch {
namespace { namespace {
#if defined(CATCH_COMPILER_MSC) #if defined(CATCH_COMPILER_MSVC)
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4146) // we negate uint32 during the rotate #pragma warning(disable:4146) // we negate uint32 during the rotate
#endif #endif
@ -24,7 +24,7 @@ namespace {
return (val >> count) | (val << (-count & mask)); return (val >> count) | (val << (-count & mask));
} }
#if defined(CATCH_COMPILER_MSC) #if defined(CATCH_COMPILER_MSVC)
#pragma warning(pop) #pragma warning(pop)
#endif #endif

View File

@ -8,12 +8,13 @@
#ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED #ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
#define CATCH_TEST_SPEC_PARSER_HPP_INCLUDED #define CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
#include <catch2/internal/catch_compiler_detections.hpp>
#ifdef CATCH_COMPILER_CLANG #ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wpadded"
#endif #endif
#include <catch2/internal/catch_compiler_detections.hpp>
#include <catch2/catch_test_spec.hpp> #include <catch2/catch_test_spec.hpp>
#include <vector> #include <vector>