IXWebSocket icon indicating copy to clipboard operation
IXWebSocket copied to clipboard

ssize_t and other libraries aren't playing nice together

Open MarkVabulas opened this issue 1 year ago • 2 comments

On line 19 in IXSocket.h, there is a typedef which reads:

typedef SSIZE_T ssize_t;

This is causing a conflict with another common library which contains the code:

typedef SSIZE_T long;

Would it be possible to push a change wrapping the SSIZE_T typedef it a #define guard:

#ifndef SSIZE_T
#define SSIZE_T ssize_t;
#endif

or alternatively with an undef such as:

#ifdef SSIZE_T
#undef SSIZE_T
#endif

I saw elsewhere it was suggested using the type std::ssize_t instead, but since that's not defined, why not change to use something like std::ptrdiff_t instead? After all, what you're passing around in the IXSocket class is usually pointer differences anyway.... It is considered bad practice to include C headers from C++ anyway, especially in header files. Including basestd.h uniquely for SSIZE_T seems like an anti-practice.

Using std::ptrdiff_t would not cause an ABI break as well.

MarkVabulas avatar Dec 22 '24 13:12 MarkVabulas