-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
Description
sockpp has its own declaration of ssize_t in platform.h, but on non-Windows systems it defines it as int. This is wrong on 64-bit OSs that use 32-bit ints, which includes all Apple platforms. (Dunno about Linux or BSD.) This leads to compile errors if a source file ends up including both platform.h and the OS's declaration. That aside, there are potentially actual integer overflow bugs if dealing with sizes > 4GB.
sockpp/include/sockpp/platform.h
Lines 78 to 86 in 180f18d
| #ifndef _SSIZE_T_DEFINED | |
| #define _SSIZE_T_DEFINED | |
| #undef ssize_t | |
| #ifdef _WIN64 | |
| using ssize_t = int64_t; | |
| #else | |
| using ssize_t = int; | |
| #endif // _WIN64 | |
| #endif // _SSIZE_T_DEFINED |
You shouldn't need to declare this at all. Instead:
On a POSIX-compliant OS,#include <sys/types.h>.- On Windows,
#include <BaseTsd.h>and thenusing ssize_t = SSIZE_T;.
(Also, it's kind of icky that the types declared in platform.h are all in the global namespace. Could they be put in the sockpp namespace like the rest of the API?)
Metadata
Metadata
Assignees
Labels
No labels