Thalhammer/jwt-cpp

picojson.h compile error

Clinkz24 opened this issue · 2 comments

d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(895): warning C4003: not enough actual parameters for macro 'min'
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(895): warning C4003: not enough actual parameters for macro 'max'
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(895): error C2589: '(': illegal token on right side of '::'
1> d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(1066): note: see reference to function template instantiation 'bool picojson::_parse<Context,Iter>(Context &,picojson::input &)' being compiled
1> with
1> [
1> Context=picojson::default_parse_context,
1> Iter=std::_String_const_iterator<std::_String_val<std::_Simple_types>>
1> ]
1> d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(1084): note: see reference to function template instantiation 'Iter picojson::_parsepicojson::default_parse_context,Iter(Context &,const Iter &,const Iter &,std::string *)' being compiled
1> with
1> [
1> Iter=std::_String_const_iterator<std::_String_val<std::_Simple_types>>,
1> Context=picojson::default_parse_context
1> ]
1> d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(1089): note: see reference to function template instantiation 'Iter picojson::parse<std::_String_const_iterator<std::_String_val<std::_Simple_types>>>(picojson::value &,const Iter &,const Iter &,std::string *)' being compiled
1> with
1> [
1> Iter=std::_String_const_iterator<std::_String_val<std::_Simple_types>>
1> ]
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(895): error C2059: syntax error: '::'
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(896): error C2143: syntax error: missing ';' before '{'
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(902): error C2065: 'f': undeclared identifier
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(902): error C2065: 'num_str': undeclared identifier
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(902): error C2228: left of '.c_str' must have class/struct/union
1> d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(902): note: type is 'unknown-type'
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(902): error C2065: 'endp': undeclared identifier
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(903): error C2065: 'endp': undeclared identifier
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(903): error C2065: 'num_str': undeclared identifier
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(903): error C2228: left of '.c_str' must have class/struct/union
1> d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(903): note: type is 'unknown-type'
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(903): error C2228: left of '.size' must have class/struct/union
1> d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(903): note: type is 'unknown-type'
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(904): error C2065: 'f': undeclared identifier
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(909): error C2043: illegal break
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(911): error C3927: '->': trailing return type is not allowed after a non-function declarator
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(911): error C3484: syntax error: expected '->' before the return type
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(911): error C3613: missing return type after '->' ('int' assumed)
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(911): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(911): error C2146: syntax error: missing ';' before identifier 'ungetc'
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(912): error C2059: syntax error: 'return'
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(913): error C2059: syntax error: '}'
1>d:\workspace\trd\curl-7.61.0\projects\windows\vc14\curl_test\jwt-cpp\picojson.h(913): error C2143: syntax error: missing ';' before '}'
1>d:\workspace\vs2015\vc\include\xutility(2982): error C2143: syntax error: missing ';' before '{'
1>d:\workspace\vs2015\vc\include\xutility(2982): error C2447: '{': missing function header (old-style formal list?)

Sorry for the late reply.

I see you're on a windows system, so I assume you include windows.h either directly or indirectly.
Windows.h (windef.h to be more specific) defines min() and max() as preprocessor macros which collide with std::numeric_limits. So you have three options:

  • define NOMINMAX, which suppresses this behaviour
  • include this library before you include windows.h
  • place #undef max and #undef min before you include this library
    Please respond if this solved it.

hi, I tried three ways you said it. They all compile correctly.
Thanks :)