From 7c507d7ebacb7bf2a08a783cfdafea67a1770bb0 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 14 Sep 2011 08:41:37 +0000 Subject: [PATCH] Made JSON_USE_EXCEPTION's value in config.h a default that can be overridden. This allows users to override it with their compiler invocation. For example: g++ -D JSON_USE_EXCEPTION=0 ... --- include/json/assertions.h | 4 ++-- include/json/config.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/json/assertions.h b/include/json/assertions.h index 5a27d5f..84eb5d7 100644 --- a/include/json/assertions.h +++ b/include/json/assertions.h @@ -13,10 +13,10 @@ # include #endif // if !defined(JSON_IS_AMALGAMATION) -#if defined(JSON_USE_EXCEPTION) +#if JSON_USE_EXCEPTION #define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw #define JSON_FAIL_MESSAGE( message ) throw std::runtime_error( message ); -#else // defined(JSON_USE_EXCEPTION) +#else // JSON_USE_EXCEPTION #define JSON_ASSERT( condition ) assert( condition ); #define JSON_FAIL_MESSAGE( message ) { std::cerr << std::endl << message << std::endl; exit(123); } #endif diff --git a/include/json/config.h b/include/json/config.h index 7609d45..72437c4 100644 --- a/include/json/config.h +++ b/include/json/config.h @@ -24,9 +24,11 @@ /// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined. //# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1 -/// If defined, indicates that Json use exception to report invalid type manipulation -/// instead of C assert macro. +// If non-zero, the library uses exceptions to report bad input instead of C +// assertion macros. The default is to use exceptions. +# ifndef JSON_USE_EXCEPTION # define JSON_USE_EXCEPTION 1 +# endif /// If defined, indicates that the source file is amalgated /// to prevent private header inclusion.