Skip to content

Replace ssize_t with std::ptrdiff_t to avoid typedef clashes on MSVC (fix #537)#597

Merged
bsergean merged 1 commit into
masterfrom
replace-ssize-t-with-ptrdiff-t
Jul 15, 2026
Merged

Replace ssize_t with std::ptrdiff_t to avoid typedef clashes on MSVC (fix #537)#597
bsergean merged 1 commit into
masterfrom
replace-ssize-t-with-ptrdiff-t

Conversation

@bsergean

Copy link
Copy Markdown
Collaborator

Fixes #537.

MSVC does not provide ssize_t, so IXSocket.h and IXUdpSocket.h injected a global-namespace typedef SSIZE_T ssize_t;. That collides (C2371) with other Windows libraries that define their own ssize_t shim with a different underlying type, as reported in #537.

This replaces every ssize_t in the library with std::ptrdiff_t and 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_t is the same underlying type as ssize_t/SSIZE_T on 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, where LONG_PTR is long but ptrdiff_t is int — same size, different mangling — so external code subclassing ix::Socket and overriding send/recv would 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; IXSocketConnectTest and IXDNSLookupTest fail 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

…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>
@bsergean
bsergean merged commit 038e0bf into master Jul 15, 2026
7 checks passed
@bsergean
bsergean deleted the replace-ssize-t-with-ptrdiff-t branch July 15, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ssize_t and other libraries aren't playing nice together

1 participant