🔨 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:
parent
ff0b18d10c
commit
65dfc97d40
2 changed files with 2 additions and 2 deletions
|
@ -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.
|
||||||
#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)
|
||||||
|
|
Loading…
Reference in a new issue