From ae24181194e6f55116be89004973c4395e533369 Mon Sep 17 00:00:00 2001 From: rhysd Date: Tue, 28 May 2019 20:34:26 +0900 Subject: [PATCH] add PICOJSON_DISABLE_EXCEPTION macro to support -fno-exceptions --- picojson.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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; }