g_strdup_printf warns on invalid format specifier with G_GUINT64_FORMAT on Win32
The docs for g_strdup_printf()
https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup-printf
tell apps to use the standard printf format specifiers, linking to
https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#string-precision
which especially tells you to use G_GUINT64_FORMAT for 64bit integers to get platform portability.
g_strdup_printf() is annotated with G_GNUC_PRINTF() which previously used 'printf' (platform specific formats), but was recently switched to 'gnu_printf' (GNU lib C formats). This switch (#1371) made sense because on platforms with broken printf (win32) the GNULIB impl is used, so it is indeed expecting GNU lib C formats.
Unfortunately when that annotation was change, G_GUINT64_FORMAT was left as it is, so it still refers to the platform specific formats.
IOW, we have a mis-match between the format string annotation and the format string macros, that causes compile warnings / errors.
$ cat mingwprintf.c
#include <glib.h>
int main(int argc, char **argv)
{
guint64 v = 0xdeadbeef;
char *s = g_strdup_printf("V: %" G_GUINT64_FORMAT "\n", v);
}
$ i686-w64-mingw32-gcc -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -mms-bitfields -I/usr/i686-w64-mingw32/sys-root/mingw/include -L/usr/i686-w64-mingw32/sys-root/mingw/lib -Wformat -o mingwprintf mingwprintf.c -lglib-2.0 -lintl
mingwprintf.c: In function 'main':
mingwprintf.c:7:29: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'guint64' {aka 'long long unsigned int'} [-Wformat=]
char *s = g_strdup_printf("V: %" G_GUINT64_FORMAT "\n", v);
^~~~~~ ~
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0/glib/gtypes.h:32,
from /usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0/glib/galloca.h:32,
from /usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0/glib.h:30,
from mingwprintf.c:1:
/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include/glibconfig.h:51:30: note: format string is defined here
#define G_GUINT64_FORMAT "I64u"
The G_GUINT64_FORMAT macro (and related ones) need fixing to use the GNU format strings that match what's actually implemented by g_strdup_printf (and related functions)