Building a testdir on mingw 13 with -D__USE_MINGW_ANSI_STDIO=0, I see this compilation error:
../../gltests/test-inttypes-h.c:70:3: error: 'SCNd8' undeclared here (not in a function) 70 | SCNd8 SCNi8 | ^~~~~ ../../gltests/test-inttypes-h.c:22:1: note: 'SCNd8' is defined in header '<inttypes.h>'; did you forget to '#include <inttypes.h>'? 21 | #include <inttypes.h> +++ |+#include <inttypes.h> 22 | ../../gltests/test-inttypes-h.c:70:9: error: expected ',' or ';' before 'SCNi8' 70 | SCNd8 SCNi8 | ^~~~~ make[4]: *** [Makefile:27184: test-inttypes-h.o] Error 1 The problem is that these macros are not defined: SCNd8 SCNi8 SCNo8 SCNu8 SCNx8 SCNdLEAST8 SCNiLEAST8 SCNoLEAST8 SCNuLEAST8 SCNxLEAST8 SCNdFAST8 SCNiFAST8 SCNoFAST8 SCNuFAST8 SCNxFAST8 apparently due to insufficient support in scanf() of msvcrt. This patch documents the problems and avoids the compilation error. 2025-09-16 Bruno Haible <br...@clisp.org> inttypes-h tests: Avoid compilation error on mingw. Reported by Michele Locati in <https://lists.gnu.org/archive/html/bug-gettext/2024-09/msg00015.html>. * tests/test-inttypes-h.c (l): On mingw without __USE_MINGW_ANSI_STDIO, don't test for the presence of SCN*8, SCN*LEAST8, SCN*FAST8}. * doc/posix-headers/inttypes.texi: Mention the mingw bug. diff --git a/doc/posix-headers/inttypes.texi b/doc/posix-headers/inttypes.texi index b3ac4104be..7d69491aae 100644 --- a/doc/posix-headers/inttypes.texi +++ b/doc/posix-headers/inttypes.texi @@ -30,7 +30,11 @@ Portability problems not fixed by Gnulib: @itemize @item -The @code{PRIb*}, @code{PRIB*}, @code{SCNb*} macros, +The macros @code{SCN*8}, @code{SCN*LEAST8}, @code{SCN*FAST8} +are missing on some platforms: +mingw without @code{__USE_MINGW_ANSI_STDIO}. +@item +The macros @code{PRIb*}, @code{PRIB*}, @code{SCNb*}, that were added in ISO C 23, are missing on many platforms: glibc 2.37 and many others. diff --git a/tests/test-inttypes-h.c b/tests/test-inttypes-h.c index 08cd32baf2..5887a2bceb 100644 --- a/tests/test-inttypes-h.c +++ b/tests/test-inttypes-h.c @@ -66,11 +66,13 @@ const char *k = /* implicit string concatenation */ #endif ; const char *l = /* implicit string concatenation */ -#ifdef INT8_MAX +#if !(defined __MINGW32__ && __USE_MINGW_ANSI_STDIO == 0) +# ifdef INT8_MAX SCNd8 SCNi8 -#endif -#ifdef UINT8_MAX +# endif +# ifdef UINT8_MAX SCNo8 SCNu8 SCNx8 +# endif #endif #ifdef INT16_MAX SCNd16 SCNi16 @@ -90,12 +92,16 @@ const char *l = /* implicit string concatenation */ #ifdef UINT64_MAX SCNo64 SCNu64 SCNx64 #endif +#if !(defined __MINGW32__ && __USE_MINGW_ANSI_STDIO == 0) SCNdLEAST8 SCNiLEAST8 SCNoLEAST8 SCNuLEAST8 SCNxLEAST8 +#endif SCNdLEAST16 SCNiLEAST16 SCNoLEAST16 SCNuLEAST16 SCNxLEAST16 SCNdLEAST32 SCNiLEAST32 SCNoLEAST32 SCNuLEAST32 SCNxLEAST32 SCNdLEAST64 SCNiLEAST64 SCNoLEAST64 SCNuLEAST64 SCNxLEAST64 +#if !(defined __MINGW32__ && __USE_MINGW_ANSI_STDIO == 0) SCNdFAST8 SCNiFAST8 SCNoFAST8 SCNuFAST8 SCNxFAST8 +#endif SCNdFAST16 SCNiFAST16 SCNoFAST16 SCNuFAST16 SCNxFAST16 SCNdFAST32 SCNiFAST32 SCNoFAST32 SCNuFAST32 SCNxFAST32 SCNdFAST64 SCNiFAST64