Replace ssize_t with std::ptrdiff_t to avoid typedef clashes on MSVC (fix #537)#597
Merged
Merged
Conversation
…ix #537) MSVC has no ssize_t, so IXSocket.h and IXUdpSocket.h injected a global 'typedef SSIZE_T ssize_t' which collides with other libraries defining their own ssize_t shim. Use std::ptrdiff_t instead, which is the same underlying type on all supported 64-bit platforms, and drop the Windows/Apple header shims entirely. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #537.
MSVC does not provide
ssize_t, soIXSocket.handIXUdpSocket.hinjected a global-namespacetypedef SSIZE_T ssize_t;. That collides (C2371) with other Windows libraries that define their ownssize_tshim with a different underlying type, as reported in #537.This replaces every
ssize_tin the library withstd::ptrdiff_tand removes both typedefs along with the now-unneeded<basetsd.h>/<sys/types.h>shim includes, so IXWebSocket no longer defines anything in the global namespace.std::ptrdiff_tis the same underlying type asssize_t/SSIZE_Ton all supported 64-bit platforms (and 32-bit Linux/macOS), so this is not an ABI break there. The one caveat is 32-bit MSVC, whereLONG_PTRislongbutptrdiff_tisint— same size, different mangling — so external code subclassingix::Socketand overridingsend/recvwould need a one-line signature update on that platform.Verified locally on macOS (SecureTransport backend, Debug,
USE_WS=1 USE_TEST=1): full build passes and the test suite gives the same results as unmodified master (16/18 pass;IXSocketConnectTestandIXDNSLookupTestfail identically on master in my environment — they depend on live network/DNS). OpenSSL, mbedTLS, and Windows paths are exercised by CI.🤖 Generated with Claude Code