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

ssize_t and other libraries aren't playing nice together #537

Open
MarkVabulas opened this issue Dec 22, 2024 · 2 comments
Open

ssize_t and other libraries aren't playing nice together #537

MarkVabulas opened this issue Dec 22, 2024 · 2 comments

Comments

@MarkVabulas
Copy link

MarkVabulas commented Dec 22, 2024

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.

@bsergean
Copy link
Collaborator

I can't remember if I tried std::ssize_t or not.

At the time I wanted to make this library C++11 compatible.

Maybe aligning to the other library would work ?
=> typedef SSIZE_T long;

@MarkVabulas
Copy link
Author

My recommendation for using std::ptrdiff was so that it would be C++11 compatible. If you changed the SSIZE_T declaration into something like using ixsize_t = std::ptrdiff_t then it would solve most of the problems and you could easily replace all instances of SSIZE_T with the new ixsize_t, right? On basically all C++11 architectures, sizeof(SSIZE_T) == sizeof(std::ptrdiff_t).

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

No branches or pull requests

2 participants