The intsafe functions give their results via a pointer, and " long long * "
cannot  be converted to " long * ".  (Yes, I think it's very weird that C
compilers are so pedantic about this by default, and it wouldn't happen in
any language I design.)

Here is some code which compiles in MSYS2's UCRT64 environment, but it's a
compilation error in the MSYS/Cygwin environment with /usr/bin/gcc:

#include <intsafe.h>
int main()
{
  INT8 x = 0;
  size_t y;
  Int8ToSizeT(x, &y);
}

$ /usr/bin/gcc scrap.c -fno-diagnostics-show-caret
scrap.c: In function 'main':
scrap.c:6:18: error: passing argument 2 of 'Int8ToUIntPtr' from
incompatible pointer type [-Wincompatible-pointer-types]
In file included from scrap.c:1:
/usr/include/w32api/intsafe.h:86:21: note: expected 'UINT_PTR *' {aka 'long
long unsigned int *'} but argument is of type 'size_t *' {aka 'long
unsigned int *'}

For the arguments that are passed by value, it's true that most users won't
care about the distinction between "long" and "long long", but it would
still cause errors if anyone wants a function pointer pointing to that
function.

--David


On Tue, Feb 24, 2026 at 3:21 AM LIU Hao <[email protected]> wrote:

> 在 2026-2-24 03:04, David Grayson 写道:
> > I tested this in the 64-bit MSYS environment from MSYS2 using my
> automated
> > test suite at https://github.com/DavidEGrayson/intsafe which checks the
> > type of each function by assigning a function pointer to point at it.  I
> > have not tested 32-bit Cygwin.
> >
> > I wasn't aware until recently that we wanted our headers to work in
> > Cygwin/MSYS.
> >
> >
> >  From 0fbfc1209762829a0d409f7a5d3c85aa46b2d3dd Mon Sep 17 00:00:00 2001
> > From: David Grayson <[email protected]>
> > Date: Mon, 23 Feb 2026 10:57:13 -0800
> > Subject: [PATCH] header/intsafe: Fix Cygwin compatibility.
> >
> > In 64-bit Cygwin, both "long" and "long long" are both 64-bit types,
> > so some 64-bit types that we assumed were the same are actually
> different.
> > - size_t (unsigned long) != UINT_PTR (unsigned long long)
> > - ptr_diff_t (long)      != INT_PTR (long long)
> Right, but I suspect it doesn't affect values of these types, and no
> compiler warns about conversion
> between `unsigned long` and `unsigned long long` in there?
>
> This isn't quite the same case as `UINT64_MAX` in the other patch; the
> latter is a standard macro, so it
> must expand to a value of the correct type.
>
>
>
> --
> Best regards,
> LIU Hao
>

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to