microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.99k stars 1.65k forks source link

Build failed on Ubuntu #1796

Open mkzz115 opened 3 months ago

mkzz115 commented 3 months ago

I build cpprestsdk in ubuntu 22.04, it occur error: eps/cpprestsdk-2.10.19/Release/src/http/common/http_helpers.cpp:91:43: error: ‘%8zX’ directive output may be truncated writing between 8 and 16 bytes into a region of size 9 [-Werror=format-truncation=] 91 | snprintf(buffer, sizeof(buffer), "%8zX", bytes_read); | ^~~~ /home/mackie/deps/cpprestsdk-2.10.19/Release/src/http/common/http_helpers.cpp:91:42: note: directive argument in the range [1, 18446744073709551615] 91 | snprintf(buffer, sizeof(buffer), "%8zX", bytes_read); | ^~~~~~ In file included from /usr/include/stdio.h:894, from /usr/include/c++/11/cstdio:42, from /usr/include/c++/11/ext/string_conversions.h:43, from /usr/include/c++/11/bits/basic_string.h:6608, from /usr/include/c++/11/string:55, from /home/mackie/deps/cpprestsdk-2.10.19/Release/src/pch/stdafx.h:52, from /home/mackie/deps/cpprestsdk-2.10.19/Release/src/http/common/http_helpers.cpp:14: /usr/include/x86_64-linux-gnu/bits/stdio2.h:71:35: note: ‘__builtin___snprintf_chk’ output between 9 and 17 bytes into a destination of size 9 71 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 72 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 73 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors make[2]: *** [Release/src/CMakeFiles/cpprest.dir/build.make:118: Release/src/CMakeFiles/cpprest.dir/http/common/http_helpers.cpp.o] Error 1 make[2]: *** Waiting for unfinished jobs....

gcc version: 11.4

op: cmake .. -DCMAKE_BUILD_TYPE=Release make -j10

mkzz115 commented 3 months ago

probably my os is 64 bit, size_t is 16 bit, so I changed char buffer[9] to char buffer[17] = {0} , then build successful

giorgiozoppi commented 2 months ago

can you provide a patch ?