Eli Zaretskii wrote:
> It turned out the root cause was that libintl.h, included by
> gettext.h, redirects the *printf functions to its own implementations,
> for example:
>
> #if !(defined sprintf && defined _GL_STDIO_H) /* don't override gnulib */
> #undef sprintf
> #define sprintf libintl_sprintf
> extern int sprintf (char *, const char *, ...);
> #endif
Yes, libintl.h does this redirection on systems where the native
*printf implementations don't support argument reordering (e.g. %1$d).
> Some of the wget2 unit tests in unit-tests/test.c fail due
> to unsupported printf specifiers, such as %hhd and %zd.
How is this possible? The replacement that libintl.h installs redirects to
a function compiled from the vasnprintf.c in gnulib. This replacement
support %hhd and %zd for more than 15 years.
- For %hhd: Search for TYPE_SCHAR.
- For %zd: On 32-bit mingw, this gets rewritten to %d. On 64-bit mingw,
this gets rewritten to %I64d (search for TYPE_LONGLONGINT).
Can you reduce the test case to a single libintl_sprintf invocation?
> The only "solution" I could
> see is to #undef all those definitions after including gettext.h, in
> source files that don't use the _ macro, but that sounds fragile, and
> doesn't work when both _() and C99 printf format specifiers are used.
>
> What is the recommended solution for this issue?
The libintl_sprintf from libintl.h ought to support %hhd, %zd perfectly
fine.
Bruno