Skip to content

Commit

Permalink
Move compiler detection header beffore using
Browse files Browse the repository at this point in the history
CATCH_COMPILER_CLANG macro. (see #2094)
  • Loading branch information
HoseynHeydari committed Apr 17, 2022
1 parent e1827f7 commit 56d04d2
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/catch2/internal/catch_compiler_capabilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) )
Expand Down
2 changes: 1 addition & 1 deletion src/catch2/internal/catch_compiler_detections.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#endif

#if defined(_MSC_VER) && !defined(__clang__)
#define CATCH_COMPILER_MSC
#define CATCH_COMPILER_MSVC
#endif

#if defined(__MINGW32__)
Expand Down
2 changes: 1 addition & 1 deletion src/catch2/internal/catch_config_uncaught_exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#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
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
# endif
Expand Down
2 changes: 1 addition & 1 deletion src/catch2/internal/catch_container_nonmembers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/catch2/internal/catch_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/catch2/internal/catch_debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/catch2/internal/catch_decomposer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <iosfwd>

#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"
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/catch2/internal/catch_output_redirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <sstream>

#if defined(CATCH_CONFIG_NEW_CAPTURE)
#if defined(CATCH_COMPILER_MSC)
#if defined(CATCH_COMPILER_MSVC)
#include <io.h> //_dup and _dup2
#define dup _dup
#define dup2 _dup2
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/catch2/internal/catch_output_redirect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
2 changes: 1 addition & 1 deletion src/catch2/internal/catch_platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/catch2/internal/catch_random_number_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/catch2/internal/catch_test_spec_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
#ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
#define CATCH_TEST_SPEC_PARSER_HPP_INCLUDED

#include <catch2/internal/catch_compiler_detections.hpp>

#ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
#endif

#include <catch2/internal/catch_compiler_detections.hpp>
#include <catch2/catch_test_spec.hpp>

#include <vector>
Expand Down

0 comments on commit 56d04d2

Please sign in to comment.