json icon indicating copy to clipboard operation
json copied to clipboard

Supported compilers

Open suy opened this issue 11 years ago • 5 comments

Hi.

There is no documentation on what compilers are supported, or which C++ features are required. I've tried to include the header in a project with MSVC 2013, and I get plenty of compile errors (with MinGW it compiles fine). I know MSVC might not have good enough C++11 support, so that's somewhat expected. I'm wondering, though, if anybody has attempted some newer pre-release of MSVC and if it is worth it at all trying to get it compile, sending patches, etc.

Thank you.

PD: In case it's useful, the first error I have is with the declaration of using iterator = basic_json::iterator:

c:\users\alex\documents\helloworld\json/src/json.hpp(142) : error C2061: syntax error : identifier 'iterator'
        c:\users\alex\documents\helloworld\json/src/json.hpp(4335) : see reference to class template instantiation 'nlohmann::basic_json<ObjectType,ArrayType,StringType,BooleanType,NumberIntegerType,NumberFloatType,Allocator>' being compiled
c:\users\alex\documents\helloworld\json/src/json.hpp(142) : error C2238: unexpected token(s) preceding ';'

Later on I get plenty of unrecognized noexcept. The later could be worked around with a macro, I think, but I have no idea on the former, or other template magic involved.

suy avatar Mar 24 '15 09:03 suy

Hi @suy,

thanks for checking by. Unfortunately, MSVC's C++11 support is still very bad. I got some pull requests where the library has been "fixed" to compile, but these changes were a preprocessor nightmare. I would also like to know how more recent versions behave.

I agree that a documentation of supported compilers would be really useful. I shall add a table to the README file and hope to get some feedback about other compilers. By the way, which compiler with MinGW did you try?

nlohmann avatar Mar 24 '15 17:03 nlohmann

El Tuesday 24 March 2015, Niels escribió:

thanks for checking by. Unfortunately, MSVC's C++11 support is still very bad. I got some pull requests where the library has been "fixed" to compile, but these changes were a preprocessor nightmare.

That's what I've always been told, and in this case I can confirm. Many errors were repeated (e.g. the lack of understanding of no_except), but the compiler stopped at the 100th error. So yeah, very problematic.

I would also like to know how more recent versions behave.

My version was 2013. I've read that people are happy about the 2015 pre- releases, but I don't have access to that myself.

I agree that a documentation of supported compilers would be really useful. I shall add a table to the README file and hope to get some feedback about other compilers. By the way, which compiler with MinGW did you try?

Thank you! Any mention of what compilers (and maybe their versions) people have reported success will be excellent. So far I can report success with MinGW 4.9.1. I can try with others if you need help in that. Thanks again.

suy avatar Mar 24 '15 21:03 suy

@suy I've just tried with the 2015 (actually, 2014, but nonetheless the latest version), and it gave me much less errors then the 2013. But the "iterator" error you reposted is still there.

if anybody is interested, I include the output of errors... can't really say why they arise, or what are they about - cpp is not my best side :)

1>  stdafx.cpp
1>\json.hpp(144): error C2061: syntax error: identifier 'iterator'
1>  \json.hpp(4523): note: see reference to class template instantiation 'nlohmann::basic_json<ObjectType,ArrayType,StringType,BooleanType,NumberIntegerType,NumberFloatType,Allocator>' being compiled
1>\json.hpp(144): error C2238: unexpected token(s) preceding ';'
1>\json.hpp(150): error C2061: syntax error: identifier 'const_iterator'
1>\json.hpp(150): error C2238: unexpected token(s) preceding ';'
1>\json.hpp(156): error C2061: syntax error: identifier 'reverse_iterator'
1>\json.hpp(156): error C2238: unexpected token(s) preceding ';'
1>\json.hpp(162): error C2061: syntax error: identifier 'const_reverse_iterator'
1>\json.hpp(162): error C2238: unexpected token(s) preceding ';'
1>\json.hpp(409): warning C4346: 'std::is_constructible<StringType,V::key_type>::value': dependent name is not a type
1>  \json.hpp(409): note: prefix with 'typename' to indicate a type
1>\json.hpp(409): error C2146: syntax error: missing '>' before identifier 'and'
1>\json.hpp(409): error C2993: 'std::enable_if<std::is_constructible<StringType,V::key_type>::value,void>': illegal type for non-type template parameter 'public: static bool const std::integral_constant<bool,0>::value'
1>\json.hpp(2049): error C2988: unrecognizable template declaration/definition
1>\json.hpp(2049): error C2059: syntax error: '<end Parse>'
1>\json.hpp(2052): error C2238: unexpected token(s) preceding ';'
1>\json.hpp(177): error C2976: 'std::map': too few template arguments
1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\map(69): note: see declaration of 'std::map'
1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(810): note: see reference to class template instantiation 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,double,std::allocator>' being compiled
1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(842): note: see reference to class template instantiation 'std::is_nothrow_constructible<_Ty,nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,double,std::allocator> &&>' being compiled
1>          with
1>          [
1>              _Ty=nlohmann::json
1>          ]
1>  \json.hpp(4549): note: see reference to class template instantiation 'std::is_nothrow_move_constructible<nlohmann::json>' being compiled
1>\json.hpp(179): error C2976: 'std::vector': too few template arguments
1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\vector(659): note: see declaration of 'std::vector'
1>\json.hpp(409): error C2993: 'std::enable_if<std::is_constructible<std::basic_string<char,std::char_traits<char>,std::allocator<char>>,V::key_type>::value,void>': illegal type for non-type template parameter 'public: static bool const std::integral_constant<bool,0>::value'
1>\json.hpp(4550): error C2146: syntax error: missing ')' before identifier 'and'
1>\json.hpp(4553): error C2039: 'swap': is not a member of 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,double,std::allocator>'
1>\json.hpp(4565): error C2039: 'dump': is not a member of 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,double,std::allocator>'
1>\json.hpp(4580): error C2039: 'parse': is not a member of 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,double,std::allocator>'
1>\json.hpp(4580): error C3861: 'parse': identifier not found

MPolovyi avatar Mar 27 '15 14:03 MPolovyi

Thank you!

suy avatar Apr 11 '15 16:04 suy

Hi @suy and @MPolovyi, I made some changes for ticket #62 which may affect MSVC support. Maybe you can check whether MSVC 2015 support is now better.

nlohmann avatar Apr 25 '15 21:04 nlohmann