Re: [PATCH] [W32] Use SSIZE_T for ssize_t on Windows instead of long
John Thacker via Gcrypt-devel <[email protected]> Thu, 21 May 2026 14:53:16 -0400
| Newsgroups | gmane.comp.encryption.gpg.libgcrypt.devel |
|---|---|
| Message-ID | <CAP_QLgotODKzZ5mXGwE7iPDJvLnmqJrMEjBBDJunm_CAbP5Hcw@mail.gmail.com> |
--===============0348478192195229449== Content-Type: multipart/alternative; boundary="000000000000ee5d880652586deb" --000000000000ee5d880652586deb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 20, 2026, 9:42=E2=80=AFPM NIIBE Yutaka via Gcrypt-devel < [email protected]> wrote: > Werner Koch wrote: > > Other opinions? > > I think that it's consisitent to use SSIZE_T. It's better to change. > > On the other hand, we know that MSVC compiles some code differently > (than developers expect). I have experiences to examine constant-time > intended code compiled by MSVC, using godbolt.org. I wonder (and am not > sure) if our libgcrypt is OK when building with MSVC. > Libgcrypt does not build with MSVC. What you can do, and Wireshark does, is build with MSYS2/MingW, which defines ssize_t as 64-bit on Win64 and 32-bit on Win32. The resultant DLL can be linked into a program when the rest of the executable and libraries are built with MSVC, and use the gcrypt.h header for necessary includes. However, this doesn't work without this patch on Win64, because the MSYS2 built DLL uses 64-bit ssize_t but MSVC will typedef ssize_t as a 32-bit long, so gcrypt.h is ABI incompatible with the built DLL. If the header typedef is patched like this, then it all works. That's even aside from the issue that Wireshark uses ssize_t in our own API. So I would say this is not an ABI break at all, but an ABI repair that makes it more consistent. I think it's still not possible to build the entire library with MSVC, but it at least makes it possible to use an unpatched gcrypt.h with a library cross compiled for Win64. Thanks, John Thacker > --000000000000ee5d880652586deb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><div><div class=3D"gmail_quote gmail_quote_container"><di= v dir=3D"ltr" class=3D"gmail_attr">On Wed, May 20, 2026, 9:42=E2=80=AFPM NI= IBE Yutaka via Gcrypt-devel <<a href=3D"mailto:[email protected]">g= [email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_qu= ote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex= ">Werner Koch wrote:<br> > Other opinions? <br> <br> I think that it's consisitent to use SSIZE_T.=C2=A0 It's better to = change.<br> <br> On the other hand, we know that MSVC compiles some code differently<br> (than developers expect).=C2=A0 I have experiences to examine constant-time= <br> intended code compiled by MSVC, using <a href=3D"http://godbolt.org" rel=3D= "noreferrer noreferrer" target=3D"_blank">godbolt.org</a>.=C2=A0 I wonder (= and am not<br> sure) if our libgcrypt is OK when building with MSVC.<br></blockquote></div= ></div><div dir=3D"auto"><br></div><div dir=3D"auto">Libgcrypt does not bui= ld with MSVC. What you can do, and Wireshark does, is build with MSYS2/Ming= W, which defines ssize_t as 64-bit on Win64 and 32-bit on Win32. The result= ant DLL can be linked into a program when the rest of the executable and li= braries are built with MSVC, and use the gcrypt.h header for necessary incl= udes.</div><div dir=3D"auto"><br></div><div dir=3D"auto">However, this does= n't work without this patch on Win64, because the MSYS2 built DLL uses = 64-bit ssize_t but MSVC will typedef ssize_t as a 32-bit long, so gcrypt.h = is ABI incompatible with the built DLL. If the header typedef is patched li= ke this, then it all works. That's even aside from the issue that Wires= hark uses ssize_t in our own API.</div><div dir=3D"auto"><br></div><div dir= =3D"auto">So I would say this is not an ABI break at all, but an ABI repair= that makes it more consistent. I think it's still not possible to buil= d the entire library with MSVC, but it at least makes it possible to use an= unpatched gcrypt.h with a library cross compiled for Win64.</div><div dir= =3D"auto"><br></div><div dir=3D"auto">Thanks,</div><div dir=3D"auto">John T= hacker</div><div dir=3D"auto"></div><div dir=3D"auto"><div class=3D"gmail_q= uote gmail_quote_container"><blockquote class=3D"gmail_quote" style=3D"marg= in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> </blockquote></div></div></div> --000000000000ee5d880652586deb-- --===============0348478192195229449== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Gcrypt-devel mailing list [email protected] https://lists.gnupg.org/mailman/listinfo/gcrypt-devel --===============0348478192195229449==--