]> Savannah Git Hosting - gnulib.git/commitdiff
error: use correct printf attributes on mingw
authorEric Blake <eblake@redhat.com>
Tue, 26 May 2015 23:26:15 +0000 (17:26 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 26 May 2015 23:32:53 +0000 (17:32 -0600)
Now that we always turn on __USE_MINGW_ANSI_STDIO when extensions
are in use, we need to replicate the same logic in error.h as
we have in stdio.h, for selecting the correct format string that
will squelch gcc -Wformat=2 warnings.

Reported by Assaf Gordon.

* lib/stdio.in.h (_GL_ATTRIBUTE_SPEC_PRINTF): New define.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
lib/error.h

index e96045b6c8e5256fe528004df6db26900b44d640..6ac962272d1415e33a8f11d1777e2be92d66ac0b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-05-26  Eric Blake  <eblake@redhat.com>
 
+       error: use correct printf attributes on mingw
+       * lib/stdio.in.h (_GL_ATTRIBUTE_SPEC_PRINTF): New define.
+
        inttypes: force correct mingw PRIdMAX even without <stdio.h>
        * modules/inttypes (Depends-on): Require extensions, so that mingw
        always uses GNU style inttypes.
index ccffef5853c9e23e678cac590f1aea144f0ad68e..9e594ced93543295a56b814457ebe2e9c8c33623 100644 (file)
 # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
 #endif
 
+/* On mingw, the flavor of printf depends on whether the extensions module
+ * is in use; the check for <stdio.h> determines the witness macro.  */
+#ifndef _GL_ATTRIBUTE_SPEC_PRINTF
+# if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU && \
+  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+#  define _GL_ATTRIBUTE_SPEC_PRINTF __gnu_printf__
+# else
+#  define _GL_ATTRIBUTE_SPEC_PRINTF __printf__
+# endif
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -40,11 +51,11 @@ extern "C" {
    If STATUS is nonzero, terminate the program with 'exit (STATUS)'.  */
 
 extern void error (int __status, int __errnum, const char *__format, ...)
-     _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
+     _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 3, 4));
 
 extern void error_at_line (int __status, int __errnum, const char *__fname,
                            unsigned int __lineno, const char *__format, ...)
-     _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6));
+     _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 5, 6));
 
 /* If NULL, error will flush stdout, then print on stderr the program
    name, a colon and a space.  Otherwise, error will call this