🔨 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.
parent ff0b18d1
...@@ -82,7 +82,7 @@ SOFTWARE. ...@@ -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)
......
...@@ -82,7 +82,7 @@ SOFTWARE. ...@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment