-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
warning: 'sprintf' is deprecated #1148
Comments
Same problem here, except that the code we were building contained |
Also seeing this on my end. It's resulting in some noisy compile logs. I'm commenting here because it looks like this particular issue has the most traction. @Shebuka It looks like a relatively trivial fix. Anybody know if the maintainers are warm to pull requests with this change? |
It's possible to disable the compile warning at the point of include. It doesn't fix the underlying problem, but if you're wanting to silence all the compiler noise (in my case) this is an option:
I've run this on gcc (windows) and clang (mac), and it seems to have worked. |
I think (but I'm not sure) this was solved in the https://github.com/chriskohlhoff/asio/releases/tag/asio-1-26-0 release. |
Note: this is not solved in 1.28 |
Are you sure to use the latest version? To double-check I've just searched |
We can't use >=1.30 due to a GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114968), and unfortunately there is one instance of asio/asio/include/asio/detail/impl/socket_ops.ipp Line 2584 in 54e3a84
It is also present in your search if go expand the match list, or search for |
Rookie mistake on the search, my bad 😅 Right now I'm building the 1.28 with Xcode 15.2 / Apple clang version 15.0.0 (clang-1500.1.0.2.5) and I have no warnings about
But asio/asio/include/asio/detail/impl/socket_ops.ipp Line 2586 in 54e3a84
That line and all the others that are still present are under ifdef |
Woops, misclick. Yes I meant that line.
We use several OS/compiler combinations, but on MacOS we use clang via brew - we don't set But I think the actual solution would be to use |
Nice find and fix in PR! 👍 |
Using
Xcode 14.0.1
withApple clang version 14.0.0 (clang-1400.0.29.102)
I get this deprecation warning:asio/ip/impl/network_v6.ipp:104:3: 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]
This points to
sprintf(prefix_len, "/%u", prefix_length_);
. Becauseprefix_len
is achar prefix_len[16];
the fix for this is quite simple, replace the line with withsnprintf(prefix_len, 16, "/%u", prefix_length_);
similar warning in other places:
asio/ip/impl/network_v4.ipp:135:3: 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]
asio/detail/impl/socket_ops.ipp:2522:7: 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]
The text was updated successfully, but these errors were encountered: