diff --git a/picojson.h b/picojson.h index 20d406c..6b6ce58 100644 --- a/picojson.h +++ b/picojson.h @@ -91,11 +91,19 @@ extern "C" { #endif #ifndef PICOJSON_ASSERT +#ifndef PICOJSON_DISABLE_EXCEPTION #define PICOJSON_ASSERT(e) \ do { \ if (!(e)) \ throw std::runtime_error(#e); \ } while (0) +#else +#define PICOJSON_ASSERT(e) \ + do { \ + if (!(e)) \ + std::abort(); \ + } while (0) +#endif // PICOJSON_DISABLE_EXCEPTION #endif #ifdef _MSC_VER @@ -245,7 +253,11 @@ inline value::value(double n) : type_(number_type), u_() { isnan(n) || isinf(n) #endif ) { +#ifndef PICOJSON_DISABLE_EXCEPTION throw std::overflow_error(""); +#else + std::abort(); +#endif } u_.number_ = n; }