kazuho / picojson

a header-file-only, JSON parser serializer in C++
BSD 2-Clause "Simplified" License
1.12k stars 222 forks source link

picojson does not support -fno-exceptions #117

Open rhysd opened 5 years ago

rhysd commented 5 years ago

Repro

  1. Put file as foo.cc with below content
  2. Run clang++ -fno-exceptions foo.cc
#include "/path/to/picojson.h"
int main() { return 0; }
// foo.cc

Expected

It compiles successfully

Actual

Many compilation errors for example:

picojson.h:1142:3: error: cannot use 'throw' with exceptions disabled
  PICOJSON_ASSERT(0);
  ^
DBJDBJ commented 4 years ago

As long as PICO JSON uses std:: it will not be usable in "no exceptions" projects.

Since PICO JSON is "pico" it will be not a big job (I assume) to make it usable with alternatives to std:: containers. One example is EASTL.

The first step might be a slight redesign so that PICO JSON itself does not throw exceptions.

rhysd commented 4 years ago

at least libc++ supports -fno-exceptions

https://reviews.llvm.org/D20677

DBJDBJ commented 4 years ago

Go ahead: fork and pull :)