From dcc04c55089b8a74c5a37e3d25694fca697ffb9f Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Mon, 20 Jul 2020 23:13:42 +0300 Subject: [PATCH] Added a workaround for uncaught_exceptions for older Mac OS and iOS. libc++ disables std::uncaught_exceptions for Mac OS < 10.12 and iOS < 10.0, even though it defines __cpp_lib_uncaught_exceptions. Fixes https://github.com/boostorg/core/issues/80. --- include/boost/core/uncaught_exceptions.hpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/include/boost/core/uncaught_exceptions.hpp b/include/boost/core/uncaught_exceptions.hpp index 4643312..e59c0f0 100644 --- a/include/boost/core/uncaught_exceptions.hpp +++ b/include/boost/core/uncaught_exceptions.hpp @@ -1,5 +1,5 @@ /* - * Copyright Andrey Semashev 2018. + * Copyright Andrey Semashev 2018 - 2020. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * https://www.boost.org/LICENSE_1_0.txt) @@ -26,8 +26,23 @@ #pragma once #endif -// Visual Studio 14 supports N4152 std::uncaught_exceptions() -#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \ +#if defined(__APPLE__) +#include +// Apple systems only support std::uncaught_exceptions starting with specific versions: +// - Mac OS >= 10.12 +// - iOS >= 10.0 +// - tvOS >= 10.0 +// - watchOS >= 3.0 +// https://github.com/boostorg/core/issues/80 +#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) && \ + ( \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || \ + (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) \ + ) +#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS +#endif +// Visual Studio 14.0 supports N4152 std::uncaught_exceptions() but doesn't define __cpp_lib_uncaught_exceptions +#elif (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \ (defined(_MSC_VER) && _MSC_VER >= 1900) #define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS #endif