pboettch / json-schema-validator

JSON schema validator for JSON for Modern C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support nlohmann JSON_DIAGNOSTICS for better exception messages

pprettysimpple opened this issue · comments

If I compile this project with this macro definition JSON_DIAGNOSTICS=1

CXXFLAGS=-DJSON_DIAGNOSTICS=1 cmake -B build
cmake --build build

or add this line at the top level of the main cmake file add_compile_definitions(-DJSON_DIAGNOSTICS=1) and run usual build.

I get a lot of warnings of that type:

/usr/include/c++/13/bits/stl_tree.h:998:16: warning: array subscript ‘std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, nlohmann::json_abi_diag_v3_11_2::basic_json<> >, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, nlohmann::json_abi_diag_v3_11_2::basic_json<> > >, std::less<void>, std::allocator<std::pair<const std::__cxx11::basic_string<char>, nlohmann::json_abi_diag_v3_11_2::basic_json<> > > >[0]’ is partly outside array bounds of ‘unsigned char [32]’ [-Warray-bounds=]
  998 |       { return iterator(this->_M_impl._M_header._M_left); }

Looks like there is no support for this nlohmann option at this moment, but I find this option really useful!

Please, tell me if I'm doing something wrong and there is a proper way to enable better exception reports.

My use-case: I want to use this option mainly for nlohmann, but if so, there is no way to call validation on that json object. Because mangled name for function differs, when compiling with or without define. And that leads to linker fail.