Files
Catch2/include/internal/catch_compiler_capabilities.h
T

127 lines
4.4 KiB
C++
Raw Normal View History

2013-04-16 22:55:31 +01: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 18:37:58 +01:00
// The following features are defined:
//
// 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?
// ****************
// Note to maintainers: if new toggles are added please document them
// in configuration.md, too
// ****************
2015-05-19 18:37:58 +01:00
2015-06-30 08:41:55 +01: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 08:41:55 +01:00
// Many features, at point of detection, define an _INTERNAL_ macro, so they
// can be combined, en-mass, with the _NO_ forms later.
2013-04-16 22:55:31 +01:00
#ifdef __cplusplus
# if __cplusplus >= 201402L
# define CATCH_CPP14_OR_GREATER
# endif
#endif
#ifdef __clang__
2017-09-07 16:51:33 +02:00
# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
_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 \
_Pragma( "clang diagnostic pop" )
# 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" )
#endif // __clang__
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
#if defined(__CYGWIN__) || defined(__QNX__)
2017-02-15 17:57:22 +01:00
# if !defined(CATCH_CONFIG_POSIX_SIGNALS)
# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
# endif
2017-04-20 21:02:25 +02:00
#endif
#ifdef __OS400__
# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
# define CATCH_CONFIG_COLOUR_NONE
#endif
2017-04-20 21:02:25 +02:00
////////////////////////////////////////////////////////////////////////////////
// Cygwin
#ifdef __CYGWIN__
2017-03-01 15:58:57 +00: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
2017-02-15 17:57:22 +01:00
#endif // __CYGWIN__
2013-04-16 22:55:31 +01:00
////////////////////////////////////////////////////////////////////////////////
// Visual C++
#ifdef _MSC_VER
2017-09-11 21:09:35 +02:00
// Universal Windows platform does not support SEH
// Or console colours (or console at all...)
# 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 22:55:31 +01:00
#endif // _MSC_VER
////////////////////////////////////////////////////////////////////////////////
2017-09-04 19:43:32 +03: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-09-04 19:43:32 +03:00
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
# define CATCH_CONFIG_COUNTER
#endif
2017-02-06 01:43:53 +01:00
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH)
# 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.
#if !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
2015-06-30 08:41:55 +01:00
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS
#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
#endif
2015-06-30 08:41:55 +01:00
2013-04-16 22:55:31 +01:00
#endif // TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED