[MinGW-Users] ISO C does not support %I64

Back to archive index
Eli Zaretskii eliz****@gnu*****
Wed Jan 27 02:10:05 JST 2021

Could someone (Keith?) please remind me how to avoid the following
compiler warning:

  D:\usr\eli>gcc -Wall -pedantic -c tsnprintf.c
  tsnprintf.c: In function 'foo':
  tsnprintf.c:8:22: warning: ISO C does not support the 'I64' mingw_printf length modifier [-Wformat=]
      8 |   snprintf (buf, 40, "%" PRIu64, bar);
	|                      ^~~

The test program is attached below.

One way of getting rid of this is to use _snprintf instead, but is
there a cleaner way?  I thought some function attribute could solve
this, perhaps?

(And please don't suggest not to use -pedantic: that's out of my
hands, since this is how the libiberty library is compiled, e.g. as
part of GNU Binutils.  Which is where I bumped into this annoyance.)


Here's the test program I used:

#include <stdio.h>
#include <inttypes.h>

char * foo (uint64_t bar)
  static char buf[80];

  snprintf (buf, 40, "%" PRIu64, bar);
  return buf;

More information about the MinGW-Users mailing list
Back to archive index