Skip to content

Commit 7c507d7

Browse files
committed
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 ...
1 parent c3763f5 commit 7c507d7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

include/json/assertions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
# include <json/config.h>
1414
#endif // if !defined(JSON_IS_AMALGAMATION)
1515

16-
#if defined(JSON_USE_EXCEPTION)
16+
#if JSON_USE_EXCEPTION
1717
#define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw
1818
#define JSON_FAIL_MESSAGE( message ) throw std::runtime_error( message );
19-
#else // defined(JSON_USE_EXCEPTION)
19+
#else // JSON_USE_EXCEPTION
2020
#define JSON_ASSERT( condition ) assert( condition );
2121
#define JSON_FAIL_MESSAGE( message ) { std::cerr << std::endl << message << std::endl; exit(123); }
2222
#endif

include/json/config.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
2525
//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1
2626

27-
/// If defined, indicates that Json use exception to report invalid type manipulation
28-
/// instead of C assert macro.
27+
// If non-zero, the library uses exceptions to report bad input instead of C
28+
// assertion macros. The default is to use exceptions.
29+
# ifndef JSON_USE_EXCEPTION
2930
# define JSON_USE_EXCEPTION 1
31+
# endif
3032

3133
/// If defined, indicates that the source file is amalgated
3234
/// to prevent private header inclusion.

0 commit comments

Comments
 (0)