Hi,

We are currently using the UCRT build of MinGW-w64 to build the Scipy
library for Python - thanks for all your work that has made this
possible.

We've run into a problem over at https://github.com/rgommers/scipy/issues/118

The essence of the problem is that the *compiler* warns when we use
the '%zd' format code to 'printf', even though the UCRT run-time does,
in fact, support this code.

This test code shows the problem:

/* test.c */
#include <stdio.h>

int main(void)
{
    size_t a = 100;
#ifdef _UCRT
    printf("We are using UCRT\n");
#endif
    printf("zd format does work;  a=%zd\n",a);
    printf("lld format also works; a=%lld\n",a);
}
/* end of test.c */

Compiling with `gcc -Wall test.c` gives:

```
test.c: In function 'main':
test.c:9:38: warning: unknown conversion type character 'z' in format [-Wformat=
]
    9 |     printf("zd format does work;  a=%zd\n",a);
      |                                      ^
test.c:9:12: warning: too many arguments for format [-Wformat-extra-args]
    9 |     printf("zd format does work;  a=%zd\n",a);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Running the generated `a.exe` gives:

```
We are using UCRT
zd format does work;  a=100
lld format also works; a=100
```

The compiler (correctly) *does not* warn for the `%lld` code,
presumably because of the guards at
https://github.com/mirror/mingw-w64/blob/master/mingw-w64-headers/crt/inttypes.h#L33
.  However, there are no such guards for the `%zd` flag, hence the
spurious warning.

We can compile with `gcc -Wall test.c -D__USE_MINGW_ANSI_STDIO=1`, to
avoid the warnings, but this gives us run-time linking with the - I
believe - slower MinGW stdio implementation, that we do not need, and
we would like to avoid.

Should there be guards for UCRT, corresponding to the e.g. `%zd`
format flags, to avoid these spurious warnings for the UCRT case?

I'm happy to give that a go if someone can point me in the right direction ...

Thanks for your help,

Matthew


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

Reply via email to