Skip to content

Commit f0fd99b

Browse files
committed
Use __has_feature(cxx_exceptions) to detect exceptions on Clang
Fixes MOODYCAMEL_EXCEPTIONS_ENABLED misdetection under Objective-C++, where __EXCEPTIONS can be set for ObjC exceptions with C++ exceptions off. Refs #435.
1 parent d655418 commit f0fd99b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

concurrentqueue.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,14 @@ namespace moodycamel { namespace details {
172172

173173
// Exceptions
174174
#ifndef MOODYCAMEL_EXCEPTIONS_ENABLED
175-
#if (defined(_MSC_VER) && defined(_CPPUNWIND)) || (defined(__GNUC__) && defined(__EXCEPTIONS)) || (!defined(_MSC_VER) && !defined(__GNUC__))
175+
// On Clang/AppleClang, __has_feature(cxx_exceptions) is the authoritative check
176+
// and correctly handles Objective-C++ where __EXCEPTIONS may be defined for
177+
// Objective-C exceptions even when C++ exceptions are disabled (see issue #435).
178+
#if defined(__has_feature)
179+
#if __has_feature(cxx_exceptions)
180+
#define MOODYCAMEL_EXCEPTIONS_ENABLED
181+
#endif
182+
#elif (defined(_MSC_VER) && defined(_CPPUNWIND)) || (defined(__GNUC__) && defined(__EXCEPTIONS)) || (!defined(_MSC_VER) && !defined(__GNUC__))
176183
#define MOODYCAMEL_EXCEPTIONS_ENABLED
177184
#endif
178185
#endif

0 commit comments

Comments
 (0)