Skip to content

Compile errors when compiling as Objective-C++ #435

@martinfinke

Description

@martinfinke

When I compile an .mm file (Objective-C++) with -fno-exceptions in Clang, __EXCEPTIONS is still #define'd to 1.
So if that .mm file #includes concurrentqueue.h, it tries to use C++ exceptions, and I get compile errors because they're disabled.

It seems that __EXCEPTIONS means: "we have some kind of exception handling (including Objective-C exceptions)", and does not mean: "C++ exceptions are enabled".

This can be solved by changing the relevant line to something like this:

#if (defined(_MSC_VER) && defined(_CPPUNWIND)) || (defined(__GNUC__) && !__OBJC__ && defined(__EXCEPTIONS)) || (__OBJC__ && __has_feature(cxx_exceptions)) || (!defined(_MSC_VER) && !defined(__GNUC__))
#define MOODYCAMEL_EXCEPTIONS_ENABLED
#endif

I'm not sure whether that's the most concise and bullet-proof predicate.

The Clang docs recommend __has_feature(cxx_exceptions), though I'm not sure about backwards-compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions