mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Fixes for MinGW compatibility
Some versions of MinGW do not support enough of Win32 API to let us work with SEH, so SEH is now MSVC only (+ configurable toggle). Also made use of gmtime_s MSVC only (as oposed to Windows only). Fixes #805
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| Catch is designed to "just work" as much as possible. For most people the only configuration needed is telling Catch which source file should host all the implementation code (```CATCH_CONFIG_MAIN```). | Catch is designed to "just work" as much as possible. For most people the only configuration needed is telling Catch which source file should host all the implementation code (```CATCH_CONFIG_MAIN```). | ||||||
|  |  | ||||||
| Nonetheless there are still some occasions where finer control is needed. For these occasions Catch exposes a small set of macros for configuring how it is built. | Nonetheless there are still some occasions where finer control is needed. For these occasions Catch exposes a set of macros for configuring how it is built. | ||||||
|  |  | ||||||
| #  main()/ implementation | #  main()/ implementation | ||||||
|  |  | ||||||
| @@ -70,6 +70,15 @@ You may also suppress any of these features by using the `_NO_` form, e.g. `CATC | |||||||
|  |  | ||||||
| All C++11 support can be disabled with `CATCH_CONFIG_NO_CPP11` | All C++11 support can be disabled with `CATCH_CONFIG_NO_CPP11` | ||||||
|  |  | ||||||
|  | # Other toggles | ||||||
|  |  | ||||||
|  |     CATCH_CONFIG_COUNTER                    // Use __COUNTER__ to generate unique names for test cases | ||||||
|  |     CATCH_CONFIG_WINDOWS_SEH                // Enable SEH handling on Windows | ||||||
|  |  | ||||||
|  | Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API supports. | ||||||
|  |  | ||||||
|  | Just as with the C++11 conformance toggles, these toggles can be disabled by using `_NO_` form of the toggle, e.g. `CATCH_CONFIG_NO_WINDOWS_SEH`. | ||||||
|  |  | ||||||
| # Windows header clutter | # Windows header clutter | ||||||
|  |  | ||||||
| On Windows Catch includes `windows.h`. To minimize global namespace clutter in the implementation file, it defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including it. You can control this behaviour via two macros: | On Windows Catch includes `windows.h`. To minimize global namespace clutter in the implementation file, it defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including it. You can control this behaviour via two macros: | ||||||
|   | |||||||
| @@ -26,6 +26,7 @@ | |||||||
|  |  | ||||||
| // CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported? | // CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported? | ||||||
| // CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? | // CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? | ||||||
|  | // CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? | ||||||
| // **************** | // **************** | ||||||
| // Note to maintainers: if new toggles are added please document them | // Note to maintainers: if new toggles are added please document them | ||||||
| // in configuration.md, too | // in configuration.md, too | ||||||
| @@ -109,6 +110,8 @@ | |||||||
| // Visual C++ | // Visual C++ | ||||||
| #ifdef _MSC_VER | #ifdef _MSC_VER | ||||||
|  |  | ||||||
|  | #define CATCH_INTERNAL_CONFIG_WINDOWS_SEH | ||||||
|  |  | ||||||
| #if (_MSC_VER >= 1600) | #if (_MSC_VER >= 1600) | ||||||
| #   define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR | #   define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR | ||||||
| #   define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR | #   define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR | ||||||
| @@ -233,6 +236,9 @@ | |||||||
| # if defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_NO_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_NO_CPP11) | # if defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_NO_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_NO_CPP11) | ||||||
| #  define CATCH_CONFIG_CPP11_TYPE_TRAITS | #  define CATCH_CONFIG_CPP11_TYPE_TRAITS | ||||||
| # endif | # endif | ||||||
|  | #if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) | ||||||
|  | #   define CATCH_CONFIG_WINDOWS_SEH | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) | #if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) | ||||||
| #   define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS | #   define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS | ||||||
|   | |||||||
| @@ -22,10 +22,17 @@ namespace Catch { | |||||||
| } // namespace Catch | } // namespace Catch | ||||||
|  |  | ||||||
| #if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// | #if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// | ||||||
|  |  | ||||||
|  |  | ||||||
| #include "catch_windows_h_proxy.h" | #include "catch_windows_h_proxy.h" | ||||||
|  |  | ||||||
|  | #  if !defined ( CATCH_CONFIG_WINDOWS_SEH ) | ||||||
|  |  | ||||||
|  | namespace Catch { | ||||||
|  |     struct FatalConditionHandler { | ||||||
|  |         void reset() {}         | ||||||
|  |     }; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #  else // CATCH_CONFIG_WINDOWS_SEH is defined | ||||||
|  |  | ||||||
| namespace Catch { | namespace Catch { | ||||||
|  |  | ||||||
| @@ -84,6 +91,8 @@ namespace Catch { | |||||||
|  |  | ||||||
| } // namespace Catch | } // namespace Catch | ||||||
|  |  | ||||||
|  | #  endif // CATCH_CONFIG_WINDOWS_SEH | ||||||
|  |  | ||||||
| #else // Not Windows - assumed to be POSIX compatible ////////////////////////// | #else // Not Windows - assumed to be POSIX compatible ////////////////////////// | ||||||
|  |  | ||||||
| #include <signal.h> | #include <signal.h> | ||||||
|   | |||||||
| @@ -26,7 +26,7 @@ namespace Catch { | |||||||
|             std::time(&rawtime); |             std::time(&rawtime); | ||||||
|             const size_t timeStampSize = sizeof("2017-01-16T17:06:45Z"); |             const size_t timeStampSize = sizeof("2017-01-16T17:06:45Z"); | ||||||
|  |  | ||||||
| #ifdef CATCH_PLATFORM_WINDOWS | #ifdef _MSC_VER | ||||||
|             std::tm timeInfo = {}; |             std::tm timeInfo = {}; | ||||||
|             gmtime_s(&timeInfo, &rawtime); |             gmtime_s(&timeInfo, &rawtime); | ||||||
| #else | #else | ||||||
| @@ -37,7 +37,7 @@ namespace Catch { | |||||||
|             char timeStamp[timeStampSize]; |             char timeStamp[timeStampSize]; | ||||||
|             const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; |             const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; | ||||||
|  |  | ||||||
| #ifdef CATCH_PLATFORM_WINDOWS | #ifdef _MSC_VER | ||||||
|             std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); |             std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); | ||||||
| #else | #else | ||||||
|             std::strftime(timeStamp, timeStampSize, fmt, timeInfo); |             std::strftime(timeStamp, timeStampSize, fmt, timeInfo); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský