bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCHv2 3/2] error: use correct printf attributes on mingw


From: Eric Blake
Subject: [PATCHv2 3/2] error: use correct printf attributes on mingw
Date: Tue, 26 May 2015 17:32:21 -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 <address@hidden>
---

Here's what I'm pushing for Assaf's latest report.

 ChangeLog   |  3 +++
 lib/error.h | 15 +++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e96045b..6ac9622 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-05-26  Eric Blake  <address@hidden>

+       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.
diff --git a/lib/error.h b/lib/error.h
index ccffef5..9e594ce 100644
--- a/lib/error.h
+++ b/lib/error.h
@@ -31,6 +31,17 @@
 # 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
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]