Windows without zlib (UWS_NO_ZLIB) #1514
-
I tried to compile using -DUWS_NO_ZLIB or /D "UWS_NO_ZLIB" with clang and cl.exe on windows and with both i got this error: uWebSockets\src\PerMessageDeflate.h(84): error C2589: '(': illegal token on right side of '::'
uWebSockets\src\PerMessageDeflate.h(84): error C2062: type 'unknown-type' unexpected
uWebSockets\src\PerMessageDeflate.h(84): error C2059: syntax error: ')' In InflationStream.inflate when using std::min i changed in my branch the code for: auto compressedLength = compressed.length();
auto min = maxPayloadLength < compressedLength ? maxPayloadLength : compressedLength;
return compressed.substr(0, min); instead of return compressed.substr(0, std::min(maxPayloadLength, compressed.length())); And all worked fine, i have not tried on linux without zlib. My cl command is something like this: cl /MD /W3 /D /EHsc /Zc:__cplusplus /Ox /DLL /D_WINDLL /LD /D "WIN32_LEAN_AND_MEAN" /D "UWS_NO_ZLIB" /D "UWS_WITH_PROXY" /D "LIBUS_USE_LIBUV" /I native/src/ /I uWebSockets/src /I uWebSockets/capi /I uWebSockets/uSockets/boringssl/include /D "LIBUS_USE_OPENSSL" /std:c++20 /I C:\vcpkg\packages\libuv_x64-windows-static-md\include /I uWebSockets/uSockets/src /Felibsocketify_windows_amd64.dll ./native/src/libsocketify.cpp uWebSockets/uSockets/src/*.c uWebSockets/uSockets/src/crypto/*.cpp uWebSockets/uSockets/src/eventing/*.c uWebSockets/uSockets/src/crypto/*.c advapi32.lib uWebSockets/uSockets/boringssl/amd64/ssl/ssl.lib uWebSockets/uSockets/boringssl/amd64/crypto/crypto.lib C:\vcpkg\installed\x64-windows-static-md\lib\uv_a.lib iphlpapi.lib userenv.lib psapi.lib user32.lib It's a bug or i have something setup wrong? EDIT: I think i got the problem, like in this answers in stackoverflow: when windows.h is included, the macro std::min expands in an broken way using in this way solves the problem too: return compressed.substr(0, std::min<size_t>(maxPayloadLength, compressed.length())); or adding NOMINMAX in the compiler when using something that includes windows.h. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
https://en.cppreference.com/w/cpp/algorithm/min Probably just need to |
Beta Was this translation helpful? Give feedback.
-
When using boringssl that includes windows.h header + DUWS_NO_ZLIB option, passing /D "NOMINMAX" in cl or -DNOMINMAX in clang solves this compilation issue, the min/max on windows.h just affect this line in a broken way, i will keep the use of |
Beta Was this translation helpful? Give feedback.
When using boringssl that includes windows.h header + DUWS_NO_ZLIB option, passing /D "NOMINMAX" in cl or -DNOMINMAX in clang solves this compilation issue, the min/max on windows.h just affect this line in a broken way, i will keep the use of
std::min<size_t>(a, b)
in my fork + /D "NOMINMAX" (if in future i drop my fork an use uWebSockets directly)