2013-04-16 23:55:31 +02:00
|
|
|
/*
|
|
|
|
* Created by Phil on 15/04/2013.
|
|
|
|
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
|
|
|
*
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*/
|
|
|
|
#ifndef TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
|
|
|
|
|
2017-04-25 12:41:30 +02:00
|
|
|
// Detect a number of compiler features - by compiler
|
2015-05-19 19:37:58 +02:00
|
|
|
// The following features are defined:
|
|
|
|
//
|
2015-12-15 08:50:51 +01:00
|
|
|
// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
|
2017-02-06 01:43:53 +01:00
|
|
|
// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported?
|
2017-02-15 17:57:22 +01:00
|
|
|
// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported?
|
2018-09-03 17:52:48 +02:00
|
|
|
// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled?
|
2015-08-11 09:09:41 +02:00
|
|
|
// ****************
|
|
|
|
// Note to maintainers: if new toggles are added please document them
|
|
|
|
// in configuration.md, too
|
|
|
|
// ****************
|
2015-05-19 19:37:58 +02:00
|
|
|
|
2015-06-30 09:41:55 +02:00
|
|
|
// In general each macro has a _NO_<feature name> form
|
2017-04-25 12:41:30 +02:00
|
|
|
// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature.
|
2015-06-30 09:41:55 +02:00
|
|
|
// Many features, at point of detection, define an _INTERNAL_ macro, so they
|
|
|
|
// can be combined, en-mass, with the _NO_ forms later.
|
|
|
|
|
2018-06-04 16:53:21 +02:00
|
|
|
#include "catch_platform.h"
|
2013-04-16 23:55:31 +02:00
|
|
|
|
2016-06-09 09:15:57 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2018-09-04 17:01:26 +02:00
|
|
|
# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
|
2016-06-09 09:15:57 +02:00
|
|
|
# define CATCH_CPP14_OR_GREATER
|
|
|
|
# endif
|
|
|
|
|
2018-09-04 17:01:26 +02:00
|
|
|
# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
|
2018-01-26 16:59:47 +01:00
|
|
|
# define CATCH_CPP17_OR_GREATER
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CATCH_CPP17_OR_GREATER)
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
2016-02-29 09:01:06 +01:00
|
|
|
#endif
|
|
|
|
|
2013-12-14 15:32:26 +01:00
|
|
|
#ifdef __clang__
|
|
|
|
|
2017-09-07 16:51:33 +02:00
|
|
|
# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
2017-03-29 20:30:59 +02:00
|
|
|
_Pragma( "clang diagnostic push" ) \
|
2017-09-07 16:51:33 +02:00
|
|
|
_Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \
|
|
|
|
_Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"")
|
|
|
|
# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \
|
2017-03-29 20:30:59 +02:00
|
|
|
_Pragma( "clang diagnostic pop" )
|
|
|
|
|
2017-02-15 10:38:38 +01:00
|
|
|
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
|
|
|
_Pragma( "clang diagnostic push" ) \
|
|
|
|
_Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
|
|
|
|
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
|
|
|
|
_Pragma( "clang diagnostic pop" )
|
2016-02-29 09:01:06 +01:00
|
|
|
|
2018-07-01 20:54:07 +02:00
|
|
|
# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \
|
|
|
|
_Pragma( "clang diagnostic push" ) \
|
|
|
|
_Pragma( "clang diagnostic ignored \"-Wunused-variable\"" )
|
|
|
|
# define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS \
|
|
|
|
_Pragma( "clang diagnostic pop" )
|
|
|
|
|
2013-12-14 15:32:26 +01:00
|
|
|
#endif // __clang__
|
|
|
|
|
2017-02-15 17:57:22 +01:00
|
|
|
|
2018-02-23 14:56:07 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Assume that non-Windows platforms support posix signals by default
|
|
|
|
#if !defined(CATCH_PLATFORM_WINDOWS)
|
|
|
|
#define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS
|
|
|
|
#endif
|
|
|
|
|
2017-02-15 17:57:22 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2017-04-20 21:02:25 +02:00
|
|
|
// We know some environments not to support full POSIX signals
|
2018-03-02 14:39:01 +01:00
|
|
|
#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__)
|
2018-03-06 17:58:37 +01:00
|
|
|
#define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
|
2017-04-20 21:02:25 +02:00
|
|
|
#endif
|
|
|
|
|
2017-07-31 10:47:42 +02:00
|
|
|
#ifdef __OS400__
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
|
|
|
|
# define CATCH_CONFIG_COLOUR_NONE
|
|
|
|
#endif
|
2017-04-20 21:02:25 +02:00
|
|
|
|
2018-05-09 20:16:27 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Android somehow still does not support std::to_string
|
|
|
|
#if defined(__ANDROID__)
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
|
|
|
|
#endif
|
2018-04-22 18:46:54 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2018-04-24 17:05:53 +02:00
|
|
|
// Not all Windows environments support SEH properly
|
2018-04-22 18:46:54 +02:00
|
|
|
#if defined(__MINGW32__)
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
|
|
|
|
#endif
|
|
|
|
|
2018-07-13 20:27:00 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// PS4
|
|
|
|
#if defined(__ORBIS__)
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE
|
|
|
|
#endif
|
|
|
|
|
2017-04-20 21:02:25 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Cygwin
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
|
2017-03-01 16:58:57 +01:00
|
|
|
// Required for some versions of Cygwin to declare gettimeofday
|
|
|
|
// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin
|
|
|
|
# define _BSD_SOURCE
|
2018-09-26 22:48:05 +02:00
|
|
|
// some versions of cygwin (most) do not support std::to_string. Use the libstd check.
|
|
|
|
// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813
|
|
|
|
# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
|
|
|
|
&& !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
|
2017-03-01 16:58:57 +01:00
|
|
|
|
2018-09-26 22:48:05 +02:00
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
|
|
|
|
|
|
|
|
# endif
|
2017-02-15 17:57:22 +01:00
|
|
|
#endif // __CYGWIN__
|
|
|
|
|
2013-04-16 23:55:31 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Visual C++
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
2018-01-26 16:59:47 +01:00
|
|
|
|
|
|
|
# if _MSC_VER >= 1900 // Visual Studio 2015 or newer
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
|
|
|
# endif
|
|
|
|
|
2017-09-11 21:09:35 +02:00
|
|
|
// Universal Windows platform does not support SEH
|
|
|
|
// Or console colours (or console at all...)
|
2017-10-30 09:27:00 +01:00
|
|
|
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
|
2017-09-11 21:09:35 +02:00
|
|
|
# define CATCH_CONFIG_COLOUR_NONE
|
|
|
|
# else
|
|
|
|
# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH
|
|
|
|
# endif
|
2017-02-06 01:43:53 +01:00
|
|
|
|
2013-04-16 23:55:31 +02:00
|
|
|
#endif // _MSC_VER
|
|
|
|
|
2015-08-11 09:09:41 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2018-09-03 17:52:48 +02:00
|
|
|
// Check if we are compiled with -fno-exceptions or equivalent
|
|
|
|
#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND)
|
|
|
|
# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED
|
|
|
|
#endif
|
2015-08-11 09:09:41 +02:00
|
|
|
|
2018-09-03 17:52:48 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2018-03-02 14:39:01 +01:00
|
|
|
// DJGPP
|
|
|
|
#ifdef __DJGPP__
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_WCHAR
|
|
|
|
#endif // __DJGPP__
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-09-04 18:43:32 +02:00
|
|
|
// Use of __COUNTER__ is suppressed during code analysis in
|
|
|
|
// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly
|
|
|
|
// handled by it.
|
|
|
|
// Otherwise all supported compilers support COUNTER macro,
|
|
|
|
// but user still might want to turn it off
|
|
|
|
#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )
|
|
|
|
#define CATCH_INTERNAL_CONFIG_COUNTER
|
|
|
|
#endif
|
2017-04-25 12:41:30 +02:00
|
|
|
|
2018-09-04 17:01:26 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Check if string_view is available and usable
|
|
|
|
// The check is split apart to work around v140 (VS2015) preprocessor issue...
|
|
|
|
#if defined(__has_include)
|
|
|
|
#if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER)
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-09-20 14:13:35 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Check if variant is available and usable
|
|
|
|
#if defined(__has_include)
|
|
|
|
# if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
|
|
|
|
# if defined(__clang__) && (__clang_major__ < 8)
|
|
|
|
// work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852
|
|
|
|
// fix should be in clang 8, workaround in libstdc++ 8.2
|
|
|
|
# include <ciso646>
|
|
|
|
# if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
|
|
|
|
# define CATCH_CONFIG_NO_CPP17_VARIANT
|
|
|
|
# else
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
|
|
|
|
# endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
|
|
|
|
# endif // defined(__clang__) && (__clang_major__ < 8)
|
|
|
|
# endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
|
|
|
|
#endif // __has_include
|
|
|
|
|
2018-09-04 17:01:26 +02:00
|
|
|
|
2017-09-04 18:43:32 +02:00
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
|
2015-12-15 08:50:51 +01:00
|
|
|
# define CATCH_CONFIG_COUNTER
|
|
|
|
#endif
|
2018-04-22 18:46:54 +02:00
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH)
|
2017-02-06 01:43:53 +01:00
|
|
|
# define CATCH_CONFIG_WINDOWS_SEH
|
|
|
|
#endif
|
2017-02-15 17:57:22 +01:00
|
|
|
// This is set by default, because we assume that unix compilers are posix-signal-compatible by default.
|
2018-02-23 14:56:07 +01:00
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)
|
2017-02-15 17:57:22 +01:00
|
|
|
# define CATCH_CONFIG_POSIX_SIGNALS
|
|
|
|
#endif
|
2018-03-01 18:41:17 +01:00
|
|
|
// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions.
|
|
|
|
#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR)
|
|
|
|
# define CATCH_CONFIG_WCHAR
|
|
|
|
#endif
|
2015-06-30 09:41:55 +02:00
|
|
|
|
2018-05-09 20:16:27 +02:00
|
|
|
#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING)
|
|
|
|
# define CATCH_CONFIG_CPP11_TO_STRING
|
|
|
|
#endif
|
|
|
|
|
2018-02-25 21:22:38 +01:00
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
|
2018-01-26 16:59:47 +01:00
|
|
|
# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
|
|
|
#endif
|
|
|
|
|
2018-09-04 17:01:26 +02:00
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW)
|
|
|
|
# define CATCH_CONFIG_CPP17_STRING_VIEW
|
|
|
|
#endif
|
|
|
|
|
2018-09-20 14:13:35 +02:00
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT)
|
|
|
|
# define CATCH_CONFIG_CPP17_VARIANT
|
|
|
|
#endif
|
|
|
|
|
2018-07-13 20:27:00 +02:00
|
|
|
#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE)
|
|
|
|
# define CATCH_CONFIG_NEW_CAPTURE
|
|
|
|
#endif
|
2018-01-26 16:59:47 +01:00
|
|
|
|
2018-09-03 17:52:48 +02:00
|
|
|
#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
|
|
|
# define CATCH_CONFIG_DISABLE_EXCEPTIONS
|
|
|
|
#endif
|
|
|
|
|
2016-02-29 09:01:06 +01:00
|
|
|
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
|
2017-02-15 10:38:38 +01:00
|
|
|
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS
|
2016-02-29 09:01:06 +01:00
|
|
|
#endif
|
2017-09-07 16:51:33 +02:00
|
|
|
#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS)
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
|
|
|
|
# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS
|
2017-03-29 20:30:59 +02:00
|
|
|
#endif
|
2018-07-01 20:54:07 +02:00
|
|
|
#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS)
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS
|
|
|
|
# define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS
|
|
|
|
#endif
|
2015-06-30 09:41:55 +02:00
|
|
|
|
2018-09-03 17:52:48 +02:00
|
|
|
#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
|
|
|
#define CATCH_TRY if ((true))
|
|
|
|
#define CATCH_CATCH_ALL if ((false))
|
|
|
|
#define CATCH_CATCH_ANON(type) if ((false))
|
|
|
|
#else
|
|
|
|
#define CATCH_TRY try
|
|
|
|
#define CATCH_CATCH_ALL catch (...)
|
|
|
|
#define CATCH_CATCH_ANON(type) catch (type)
|
|
|
|
#endif
|
|
|
|
|
2015-08-11 09:09:41 +02:00
|
|
|
|
2013-04-16 23:55:31 +02:00
|
|
|
#endif // TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
|
|
|
|
|