🔨 using __cpp_exceptions to detect exception support #498

I used __EXCEPTIONS to detect whether exceptions are supported.
Apparently, this is a macro that is only used by libstdc++
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64276). It’s much cleaner
to use __cpp_exceptions as it is in the standard since C++98.

Note that compiling the unit-tests with “-fno-exceptions” still does
not work, because Catch uses throw internally. However, the library’s
exceptions can be switched off by defining JSON_NOEXCEPTION.
This commit is contained in:
Niels Lohmann 2017-03-11 17:44:54 +01:00
parent ff0b18d10c
commit 65dfc97d40
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
2 changed files with 2 additions and 2 deletions

View file

@ -82,7 +82,7 @@ SOFTWARE.
#endif #endif
// allow to disable exceptions // allow to disable exceptions
#if not defined(JSON_NOEXCEPTION) || defined(__EXCEPTIONS) #if __cpp_exceptions && not defined(JSON_NOEXCEPTION)
#define JSON_THROW(exception) throw exception #define JSON_THROW(exception) throw exception
#define JSON_TRY try #define JSON_TRY try
#define JSON_CATCH(exception) catch(exception) #define JSON_CATCH(exception) catch(exception)

View file

@ -82,7 +82,7 @@ SOFTWARE.
#endif #endif
// allow to disable exceptions // allow to disable exceptions
#if not defined(JSON_NOEXCEPTION) || defined(__EXCEPTIONS) #if __cpp_exceptions && not defined(JSON_NOEXCEPTION)
#define JSON_THROW(exception) throw exception #define JSON_THROW(exception) throw exception
#define JSON_TRY try #define JSON_TRY try
#define JSON_CATCH(exception) catch(exception) #define JSON_CATCH(exception) catch(exception)