In order to avoid some problem with VS2017 I've put this line in my json.hpp 2.1.1
ifdef WIN32
define NOMINMAX
undef min
#undef max
endif
just after #define NLOHMANN_JOSN_HPP
I don't know how to fix it properly
Thanks for reporting. Could you please post the error message that occurs when you don't add the fix?
many of them:
json.hpp(6702): warning C4003: not enough actual parameters for macro 'max'
json.hpp(6716): warning C4003: not enough actual parameters for macro 'min'
json.hpp(6926): error C2589: '(': illegal token on right side of '::'
json.hpp(6900): note: while compiling class template member function 'void nlohmann::basic_json
with
[
_Ty=uint8_t
]
json.hpp(8008): note: see reference to function template instantiation 'void nlohmann::basic_json
with
[
_Ty=uint8_t
]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(707): note: see reference to class template instantiation 'nlohmann::basic_json
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(736): note: see reference to class template instantiation 'std::is_nothrow_constructible<_Ty,nlohmann::basic_json
with
[
_Ty=nlohmann::json
]
json.hpp(12932): note: see reference to class template instantiation 'std::is_nothrow_move_constructible
json.hpp(6926): error C2062: type 'unknown-type' unexpected
json.hpp(6926): error C2059: syntax error: ')'
json.hpp(6927): error C2143: syntax error: missing ';' before '{'
json.hpp(6932): error C2181: illegal else without matching if
json.hpp(6932): error C2589: '(': illegal token on right side of '::'
json.hpp(6932): error C2062: type 'unknown-type' unexpected
json.hpp(6932): error C2059: syntax error: ')'
json.hpp(6933): error C2143: syntax error: missing ';' before '{'
json.hpp(6938): error C2181: illegal else without matching if
json.hpp(6938): error C2589: '(': illegal token on right side of '::'
json.hpp(6938): error C2062: type 'unknown-type' unexpected
json.hpp(6938): error C2059: syntax error: ')'
json.hpp(6939): error C2143: syntax error: missing ';' before '{'
json.hpp(6944): error C2181: illegal else without matching if
json.hpp(6960): error C2589: '(': illegal token on right side of '::'
json.hpp(6960): error C2062: type 'unknown-type' unexpected
json.hpp(6960): error C2059: syntax error: ')'
json.hpp(6961): error C2143: syntax error: missing ';' before '{'
json.hpp(6966): error C2181: illegal else without matching if
json.hpp(6966): error C2589: '(': illegal token on right side of '::'
json.hpp(6966): error C2062: type 'unknown-type' unexpected
json.hpp(6966): error C2059: syntax error: ')'
json.hpp(6967): error C2143: syntax error: missing ';' before '{'
json.hpp(6972): error C2181: illegal else without matching if
json.hpp(6972): error C2589: '(': illegal token on right side of '::'
json.hpp(6972): error C2062: type 'unknown-type' unexpected
json.hpp(6972): error C2059: syntax error: ')'
json.hpp(6973): error C2143: syntax error: missing ';' before '{'
json.hpp(6978): error C2181: illegal else without matching if
From what I learned about here, this is not a bug in the library, but in headers like <Windows.h> or WinDef.h. It seems that one of this headers where included prior to json.hpp. A better way is described here:
#define NOMINMAX
#include <windows.h>
#undef NOMINMAX
The library is not even using std::max, but std::numeric_limits<T>::max.
thanks let me check
works perfectly!
Great. I shall merge the fix to develop. Please note that this branch is experimental and may change until version 3.0.0 is released.
ok thanks
From what I learned about here, this is not a bug in the library, but in headers like
<Windows.h>orWinDef.h. It seems that one of this headers where included prior tojson.hpp. A better way is described here:#define NOMINMAX #include <windows.h> #undef NOMINMAXThe library is not even using
std::max, butstd::numeric_limits<T>::max.
it's helpful,thanks a lot
Most helpful comment
From what I learned about here, this is not a bug in the library, but in headers like
<Windows.h>orWinDef.h. It seems that one of this headers where included prior tojson.hpp. A better way is described here:The library is not even using
std::max, butstd::numeric_limits<T>::max.