nmos-cpp
nmos-cpp copied to clipboard
Warnings compiling ws_listener_impl.cpp in VS 2017
There are several warnings building ws_listener_impl.cpp under VS 2017. These seem to be coming from the cpprestsdk-2.10.11 library so maybe this issue is in the wrong place. See messages below. The warnings don't really identify the location of the source code so they are hard to track down.
The first error is related to the websocketpp::utility::to_lower function in utilities_impl.hpp. Adding a cast seems to satisfy the warning but the return value from tolower() could be -1 and that is not really handled.
inline std::string to_lower(std::string const& in)
{
std::string out = in;
std::transform(out.begin(), out.end(), out.begin(), [](char c) { return (char)::tolower(c); });
return out;
}
The others seem more subtle and coming from frame.hpp with the extended_header functions.
1>ws_listener_impl.cpp 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\algorithm(1443): warning C4244: '=': conversion from 'int' to 'char', possible loss of data 1>e:\projects\3rdparty\cpprestsdk\cpprestsdk-2.10.11-nmos-cpp\cpprestsdk\release\libs\websocketpp\websocketpp\impl\utilities_impl.hpp(39): note: see reference to function template instantiation '_OutIt std::transform<:_string_iterator>>>,std::_String_iterator<:_string_val>>>,int(__cdecl *)(int)>(const _InIt,const _InIt,_OutIt,_Fn)' being compiled 1> with 1> [ 1> _OutIt=std::_String_iterator<:_string_val>>>, 1> _Ty=char, 1> _InIt=std::_String_iterator<:_string_val>>>, 1> _Fn=int (__cdecl *)(int) 1> ] 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\xutility(2949): warning C4244: '=': conversion from 'const _Ty' to '_Ty', possible loss of data 1> with 1> [ 1> _Ty=int 1> ] 1> and 1> [ 1> _Ty=uint8_t 1> ] 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\xutility(2972): note: see reference to function template instantiation '_OutIt *std::_Fill_n_unchecked2<_ty int>(_OutIt,_Diff,const int &,std::false_type)' being compiled 1> with 1> [ 1> _OutIt=uint8_t *, 1> _Ty=uint8_t, 1> _Diff=unsigned int 1> ] 1>e:\projects\3rdparty\cpprestsdk\cpprestsdk-2.10.11-nmos-cpp\cpprestsdk\release\libs\websocketpp\websocketpp\frame.hpp(237): note: see reference to function template instantiation '_OutIt *std::fill_n(_OutIt,_Diff,const _Ty &)' being compiled 1> with 1> [ 1> _OutIt=uint8_t *, 1> _Diff=unsigned int, 1> _Ty=int 1> ]
Looks like all of those are due to websocketpp, and mostly harmless.
See https://github.com/zaphoyd/websocketpp/pull/758 for someone else's attempt to resolve these, and https://en.cppreference.com/w/cpp/string/byte/tolower#Notes.
These are still not fixed in upstream websocketpp, though more people have submitted similar PRs... see https://github.com/zaphoyd/websocketpp/pull/767 and https://github.com/zaphoyd/websocketpp/pull/783