From 292f81e5efc7a847a2bd69a7dccb289588193a9e Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Tue, 17 Nov 2015 15:07:51 -0800 Subject: [PATCH] Tidied up compiler-config macros. --- include/span.h | 29 +++++++++++++++++++++++++---- include/string_span.h | 2 -- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/span.h b/include/span.h index be7e74f..6882f40 100644 --- a/include/span.h +++ b/include/span.h @@ -39,16 +39,21 @@ #pragma push_macro("constexpr") #define constexpr /* nothing */ +// MSVC has the potential of bringing in headers where max is a macro +#ifdef max +#pragma push_macro("max") +#undef max +#endif // VS 2013 workarounds #if _MSC_VER <= 1800 -#pragma push_macro("GSL_MSVC_HAS_VARIADIC_CTOR_BUG") +// needed in span.h #define GSL_MSVC_HAS_VARIADIC_CTOR_BUG - // noexcept is not understood #ifndef GSL_THROWS_FOR_TESTING +#pragma push_macro("noexcept") #define noexcept /* nothing */ #endif @@ -63,7 +68,13 @@ // In order to test the library, we need it to throw exceptions that we can catch #ifdef GSL_THROWS_FOR_TESTING + +#ifdef _MSC_VER +#pragma push_macro("noexcept") +#endif + #define noexcept /* nothing */ + #endif // GSL_THROWS_FOR_TESTING @@ -2029,28 +2040,38 @@ general_span_iterator operator+(typename general_span_iterator::diff } // namespace gsl + #ifdef _MSC_VER #undef constexpr #pragma pop_macro("constexpr") +#ifdef max +#pragma pop_macro("max") +#endif + #if _MSC_VER <= 1800 #pragma warning(pop) #ifndef GSL_THROWS_FOR_TESTING #pragma undef noexcept +#pragma pop_macro("noexcept") #endif // GSL_THROWS_FOR_TESTING #undef GSL_MSVC_HAS_VARIADIC_CTOR_BUG -#pragma pop_macro("GSL_MSVC_HAS_VARIADIC_CTOR_BUG") - #endif // _MSC_VER <= 1800 #endif // _MSC_VER #if defined(GSL_THROWS_FOR_TESTING) + #undef noexcept + +#ifdef _MSC_VER +#pragma pop_macro("noexcept") +#endif + #endif // GSL_THROWS_FOR_TESTING diff --git a/include/string_span.h b/include/string_span.h index 7194c85..b30ebf0 100644 --- a/include/string_span.h +++ b/include/string_span.h @@ -26,7 +26,6 @@ #ifdef _MSC_VER #if _MSC_VER <= 1800 -#pragma push_macro("GSL_MSVC_HAS_TYPE_DEDUCTION_BUG") #define GSL_MSVC_HAS_TYPE_DEDUCTION_BUG #endif // _MSC_VER <= 1800 @@ -217,7 +216,6 @@ using wzstring_builder = basic_zstring_builder; #ifdef _MSC_VER #if _MSC_VER <= 1800 -#pragma pop_macro("GSL_MSVC_HAS_TYPE_DEDUCTION_BUG") #undef GSL_MSVC_HAS_TYPE_DEDUCTION_BUG #endif // _MSC_VER <= 1800