kevinkreiser / prime_server

non-blocking (web)server API for distributed computing and SOA based on zeromq
Other
59 stars 26 forks source link

Building on Sonoma with clang 15 fails with `sprintf` deprecation error #130

Closed lemvik closed 11 months ago

lemvik commented 11 months ago

When running the cmake --build build one gets:

% cmake --build build
[  3%] Building CXX object CMakeFiles/prime_server.dir/src/http_protocol.cpp.o
In file included from <redacted>/prime_server/src/http_protocol.cpp:2:
<redacted>/prime_server/src/logging/logging.hpp:66:5: error: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Werror,-Wdeprecated-declarations]
    sprintf(&buffer.front(), "%04d/%02d/%02d %02d:%02d:%09.6f", gmt.tm_year + 1900, gmt.tm_mon + 1,
    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/include/stdio.h:180:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))

clang version output (x86_64 here because I built prime_server under rosetta):

% clang --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: x86_64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Apparently this deprecation appeared in the toolchain of XCode 14 (some thread in Apple support)

lemvik commented 11 months ago

For now I've patched the CMakeLists.txt locally with

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
kevinkreiser commented 11 months ago

I've fixed this in a downstream project and will back port to this project. see comments here https://gist.github.com/kevinkreiser/39f2e39273c625d96790?permalink_comment_id=4752985#gistcomment-4752985

kevinkreiser commented 11 months ago

should be fixed