lib/stdio.in.h has this fragment: /* _GL_ATTRIBUTE_FORMAT_PRINTF indicates to GCC that the function takes a format string and arguments, where the format string directives are the ones standardized by ISO C99 and POSIX. */ #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument ))
However, __gnu_printf__ is documented to refer to formats accepted by the GNU C library, so it's potentially inappropriate on non-glibc systems. In particular, MinGW builds that use this definition of _GL_ATTRIBUTE_FORMAT emit bogus compilation warnings, like this one: tfmt.c: In function 'foo': tfmt.c:13:39: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long long int' [-Wformat=] return make_formatted_string (name, "F%" PRIdMAX, count); because PRIdMAX is defined as "I64d" in the MinGW headers, and __gnu_printf__ evidently doesn't recognize that specifier. What's more serious, using __gnu_printf__ will not flag the use of %lld for formatting long long values, which will cause run-time errors. Using __ms_printf__ instead of __gnu_printf__ makes these problems go away in a MinGW build. Bottom line, I don't think __gnu_printf__ should be used on non-glibc platforms. Thanks.