Skip to content

C++ siteupdate: Use of sprintf, deprecated on MacOS/XCode #585

Closed
@jteresco

Description

@jteresco

When compiling on MacOS, the C++ site update code generates pages of warnings:

siteupdate.cpp:527:4: warning: '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. [-Wdeprecated-declarations]
                        sprintf(fstr, ": %.2f mi", cr->mileage);
                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:188: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.")

I'm ok leaving it or replacing our sprintf calls with snprintf calls. A little of what I saw when searching around on this is that there are also some more C++-specific ways to achieve the same result.

Compiler version:

Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions