asio icon indicating copy to clipboard operation
asio copied to clipboard

Fix sprintf issue on MacOS for non-XCode compilers

Open stephanlachnit opened this issue 7 months ago • 0 comments

@chriskohlhoff @klemens-morgenstern

This should fix the sprintf issue on MacOS for good, in particular if XCode is not used but e.g. clang from brew (see https://github.com/chriskohlhoff/asio/issues/1148 for discussion).

The issue is the check of ASIO_HAS_SNPRINTF here: https://github.com/chriskohlhoff/asio/blob/54e3a844eb5f31d25416de9e509d9c24fa203c32/asio/include/asio/detail/config.hpp#L1411-L1420

It only checks if __apple_build_version__ is defined, however this variable isn't set when using non-XCode compilers on MacOS. Since snprintf is available in MacOS since version 10.0, which was released in March 2001, is think the best option is to always set ASIO_HAS_SNPRINTF if __APPLE__ is detected.

Note that is also fixes a missing instance where sprintf_s can be used via Microsoft RTL.

Closes https://github.com/chriskohlhoff/asio/issues/1148 closes https://github.com/chriskohlhoff/asio/issues/1449 closes https://github.com/chriskohlhoff/asio/issues/1183

stephanlachnit avatar Jul 11 '24 08:07 stephanlachnit