Skip to content

Error compiling with clang and JSON_NOEXCEPTION: need to include cstdlib #1500

Description

Compiling with clang (v. 5.0.0, x84_64 linux) with JSON_NOEXCEPTION defined produces error

/path/to/include/nlohmann/detail/conversions/from_json.hpp:31:9: error: no member named 'abort' in namespace 'std'; did you mean simply 'abort'?
        JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name())));
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/path/to/include/nlohmann/detail/macro_scope.hpp:47:35: note: expanded from macro 'JSON_THROW'
    #define JSON_THROW(exception) std::abort()

This is because std::abort is defined in <cstdlib> and nowhere does this library include <cstdlib>.

I don't have a MWE to hand, this error was discovered using the Unreal build tool on Linux, which may be passing some unconventional arguments to clang and I don't have time right now to find the reproduction steps. In any case, <cstdlib> should be included when std::abort is being used.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions