mirror of
https://github.com/nlohmann/json.git
synced 2025-07-24 02:21:01 +03:00
🔨 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:
@ -82,7 +82,7 @@ SOFTWARE.
|
||||
#endif
|
||||
|
||||
// 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_TRY try
|
||||
#define JSON_CATCH(exception) catch(exception)
|
||||
|
Reference in New Issue
Block a user