64-bit Windows uses a LLP64 data model, where long is still 32 bits and long long and pointers are 64-bits. The SSIZE_T Windows Data Type from basetsd.h is 32-bits on Win32 and 64-bits on Win64, and is intended for the same purposes as the POSIX ssize_t. It is what Wireshark uses in its POSIX compatibility header for Windows, and would prevent Wireshark from having to change the definition when compiling for Windows. Other attempts to make libgcrypt more compatible with MSVC used the same approach. Patch attached.
Thanks, John Thacker
From 313be5e71e850c288fda6678862e4b6ada13f396 Mon Sep 17 00:00:00 2001 From: John Thacker <[email protected]> Date: Tue, 19 May 2026 17:48:58 -0400 Subject: [PATCH] Win32: Type SSIZE_T as ssize_t instead of long 64-bit Windows uses a LLP64 data model, where long is still 32 bits and long long and pointers are 64-bits. basetsd.h defines Windows Data Types, including a SSIZE_T which is 32-bit on 32-bit Windows and 64-bit on 64-bit Windows and intended for the same purpose as POSIX ssize_t. Use that for the ssize_t typedef. This is what the recently on hiatus ShiftMediaProject Windows port of libgcrypt did (https://github.com/ShiftMediaProject/libgcrypt/blob/master/src/gcrypt.h.in) and also matches what some other projects like Wireshark use. Signed-off-by: John Thacker <[email protected]> --- src/gcrypt.h.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index 04339a48..73e54bf3 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -35,7 +35,8 @@ #if defined _WIN32 || defined __WIN32__ # ifndef __GNUC__ - typedef long ssize_t; +# include <basetsd.h> + typedef SSIZE_T ssize_t; typedef int pid_t; # endif /*!__GNUC__*/ #endif /*_WIN32*/ -- 2.54.0
_______________________________________________ Gcrypt-devel mailing list [email protected] https://lists.gnupg.org/mailman/listinfo/gcrypt-devel
