Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building fails using single include file: json.hpp #1308

Closed
octavian-sandru opened this issue Oct 19, 2018 · 7 comments
Closed

Building fails using single include file: json.hpp #1308

octavian-sandru opened this issue Oct 19, 2018 · 7 comments

Comments

@octavian-sandru
Copy link

octavian-sandru commented Oct 19, 2018

I just downloaded json.hpp and placed it directly in my source folder.
I then include it in my .cc file:

#include "json.hpp"
using json = nlohmann::json;

and I define a static method:

static void ParseAndInterpretIncomingData(const uint8_t* data, size_t size) {
  json dataObj = json::parse(data, data + size);
}

But when I build, I get these errors directly coming from line where I include the json.hpp:

<my source folder>/json.hpp: In instantiation of ‘constexpr const bool nlohmann::detail::is_constructible_object_type_impl<nlohmann::basic_json<>, std::map<std::basic_string<char>, nlohmann::basic_json<>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, nlohmann::basic_json<> > > >, void>::value’:

<my source folder>/json.hpp:1407:106:   required by substitution of ‘template<class BasicJsonType, class T> decltype ((nlohmann::detail::from_json(j, val), void())) nlohmann::detail::from_json_fn::operator()(const BasicJsonType&, T&) const [with BasicJsonType = nlohmann::basic_json<>; T = std::map<std::basic_string<char>, nlohmann::basic_json<>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, nlohmann::basic_json<> > > >]’

<my source folder>/json.hpp:11530:70:   required by substitution of ‘template<class BasicJsonType, class ValueType> static decltype ((nlohmann::{anonymous}::from_json(forward<BasicJsonType>(j), val), void())) nlohmann::adl_serializer<T, SFINAE>::from_json(BasicJsonType&&, ValueType&) [with BasicJsonType = BasicJsonType; ValueType = ValueType; <template-parameter-1-1> = std::map<std::basic_string<char>, nlohmann::basic_json<>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, nlohmann::basic_json<> > > >; <template-parameter-1-2> = void] [with BasicJsonType = const nlohmann::basic_json<>&; ValueType = std::map<std::basic_string<char>, nlohmann::basic_json<>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, nlohmann::basic_json<> > > >]’

<my source folder>/json.hpp:435:73:   required by substitution of ‘template<class T, class ... Args> using from_json_function = decltype (T:: from_json((declval<Args>)()...)) [with T = nlohmann::adl_serializer<std::map<std::basic_string<char>, nlohmann::basic_json<>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, nlohmann::basic_json<> > > >, void>; Args = {const nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer>&, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer>, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer> > > >&}]’

<my source folder>/json.hpp:362:74:   required by substitution of ‘template<class Expected, template<class ...> class Op, class ... Args> using is_detected_exact = std::is_same<Expected, typename nlohmann::detail::detector<nlohmann::detail::nonesuch, void, Op, Args ...>::type> [with Expected = void; Op = nlohmann::detail::from_json_function; Args = {nlohmann::basic_json<>::json_serializer<std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer>, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer> > > >, void>, const nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer>&, std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer>, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer> > > >&}]’

<my source folder>/json.hpp:450:27:   required from ‘constexpr const bool nlohmann::detail::has_from_json<nlohmann::basic_json<>, std::map<std::basic_string<char>, nlohmann::basic_json<>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, nlohmann::basic_json<> > > >, void>::value’
<my source folder>/json.hpp:14047:62:   required by substitution of ‘template<class T, class U> using get_template_function = decltype (declval<T>().get<U>()) [with T = const nlohmann::basic_json<>&; U = std::map<std::basic_string<char>, nlohmann::basic_json<>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, nlohmann::basic_json<> > > >]’
<my source folder>/json.hpp:14338:20:   required from here
<my source folder>/json.hpp:557:63: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
         typename ConstructibleObjectType::mapped_type>::value or
@gregmarr
Copy link
Contributor

gregmarr commented Oct 19, 2018

/json.hpp:557:63: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
typename ConstructibleObjectType::mapped_type>::value or

Did you try disabling this error around the include?

@octavian-sandru
Copy link
Author

I wish I could do that, if I knew how

@nlohmann
Copy link
Owner

Can you compile and run the test suite?

@octavian-sandru
Copy link
Author

I'm thinking I'm not using the right C++ compiler version. C++11 should do it...

@nlohmann
Copy link
Owner

So is the issue solved?

@octavian-sandru
Copy link
Author

no I gave up. For me it was a temporary thing anyways to parse data incoming data in C++. Will accomplish this in JavaScript

@Rasnar
Copy link

Rasnar commented Oct 25, 2018

Hello!
I have the same problem as stated by octavian-sandru :

json/single_include/nlohmann/json.hpp:1407:106:   required by substitution of 'template<class BasicJsonType, class ConstructibleObjectType, typename std::__1::enable_if<nlohmann::detail::is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int>::type <anonymous> > void nlohmann::detail::from_json(const BasicJsonType&, ConstructibleObjectType&) [with BasicJsonType = nlohmann::basic_json<>; ConstructibleObjectType = std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<>, std::__1::less<void>, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<> > > >; typename std::__1::enable_if<nlohmann::detail::is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int>::type <anonymous> = <missing>]'

json/single_include/nlohmann/json.hpp:1529:26:   required by substitution of 'template<class BasicJsonType, class T> decltype ((nlohmann::detail::from_json(j, val), void())) nlohmann::detail::from_json_fn::operator()(const BasicJsonType&, T&) const [with BasicJsonType = nlohmann::basic_json<>; T = std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<>, std::__1::less<void>, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<> > > >]'

json/single_include/nlohmann/json.hpp:11635:34:   required by substitution of 'template<class BasicJsonType, class ValueType> static decltype ((nlohmann::{anonymous}::from_json(forward<BasicJsonType>(j), val), void())) nlohmann::adl_serializer<T, SFINAE>::from_json(BasicJsonType&&, ValueType&) [with BasicJsonType = const nlohmann::basic_json<>&; ValueType = std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<>, std::__1::less<void>, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<> > > >]'

single_include/nlohmann/json.hpp:1529:26:   required by substitution of 'template<class BasicJsonType, class T> decltype ((nlohmann::detail::from_json(j, val), void())) nlohmann::detail::from_json_fn::operator()(const BasicJsonType&, T&) const [with BasicJsonType = nlohmann::basic_json<>; T = std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<>, std::__1::less<void>, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<> > > >]'

json/single_include/nlohmann/json.hpp:450:27:   required from 'constexpr const bool nlohmann::detail::has_from_json<nlohmann::basic_json<>, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<>, std::__1::less<void>, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<> > > >, void>::value'

json/single_include/nlohmann/json.hpp:438:76:   required by substitution of 'template<class T, class U> using get_template_function = decltype (declval<T>().get<U>()) [with T = const nlohmann::basic_json<>&; U = std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<>, std::__1::less<void>, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, nlohmann::basic_json<> > > >]'

But only if I use the version HEAD at f102df3 (no errors if I use the tag v3.3.0).

I'm in a bit of a strange place because I'm cross-compiling with QNX. I compile for two target, the first is my native Linux machine that is used for some unit tests (g++ v6.3) and the second is my QNX target. The Linux compilation do not show the errors stated beforehand.
For my QNX compilation, those are my versions of the compiler :

$ q++ -V
cc: targets available in /home/debian/qnx700/host/linux/x86_64/etc/qcc:
	5.4.0,gcc_ntox86_64_gpp	
	5.4.0,gcc_ntox86_64_cxx	
	5.4.0,gcc_ntoaarch64le	
	5.4.0,gcc_ntoaarch64le_gpp	
	5.4.0,gcc_ntoaarch64le_cxx	
	5.4.0,gcc_ntoarmv7le_gpp	
	5.4.0,gcc_ntox86_gpp	
	5.4.0,gcc_ntoarmv7le	
	5.4.0,gcc_ntox86_cxx	
	5.4.0,gcc_ntox86	(default)
	5.4.0,gcc_ntox86_64	
	5.4.0,gcc_ntoarmv7le_cxx

I will stick with the version 3.3.0 for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants