asio
asio copied to clipboard
warning: 'sprintf' is deprecated
Using Xcode 14.0.1
with Apple 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_);
. Because prefix_len
is a char prefix_len[16];
the fix for this is quite simple, replace the line with with snprintf(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]