Skip to content
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

Fix sprintf issue on MacOS for non-XCode compilers #1510

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions asio/include/asio/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,11 +1411,9 @@
// Standard library support for snprintf.
#if !defined(ASIO_HAS_SNPRINTF)
# if !defined(ASIO_DISABLE_SNPRINTF)
# if defined(__apple_build_version__)
# if (__clang_major__ >= 14)
# define ASIO_HAS_SNPRINTF 1
# endif // (__clang_major__ >= 14)
# endif // defined(__apple_build_version__)
# if defined(__APPLE__)
# define ASIO_HAS_SNPRINTF 1
# endif // defined(__APPLE__)
# endif // !defined(ASIO_DISABLE_SNPRINTF)
#endif // !defined(ASIO_HAS_SNPRINTF)

Expand Down
6 changes: 4 additions & 2 deletions asio/include/asio/detail/impl/socket_ops.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -2582,9 +2582,11 @@ const char* inet_ntop(int af, const void* src, char* dest, size_t length,
|| if_indextoname(static_cast<unsigned>(scope_id), if_name + 1) == 0)
#if defined(ASIO_HAS_SNPRINTF)
snprintf(if_name + 1, sizeof(if_name) - 1, "%lu", scope_id);
#else // defined(ASIO_HAS_SNPRINTF)
#elif defined(ASIO_HAS_SECURE_RTL)
sprintf_s(if_name + 1, sizeof(if_name) -1, "%lu", scope_id);
#else // defined(ASIO_HAS_SECURE_RTL)
sprintf(if_name + 1, "%lu", scope_id);
#endif // defined(ASIO_HAS_SNPRINTF)
#endif // defined(ASIO_HAS_SECURE_RTL)
strcat(dest, if_name);
}
return result;
Expand Down