bug-gnulib
[Top][All Lists]
Advanced

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

[PATCHv2 4/2] stdio: limit __gnu_printf__ witness to gcc 4.4+


From: Eric Blake
Subject: [PATCHv2 4/2] stdio: limit __gnu_printf__ witness to gcc 4.4+
Date: Tue, 26 May 2015 21:31:17 -0600

If we start adding more places that need to conditionally label
functions with __gnu_printf__, it will be nicer if the logic for
determining that gcc even supports that attribute is done once
up front rather than in each caller.

* lib/error.h (_GL_ATTRIBUTE_SPEC_PRINTF): Move gcc version probe...
* m4/stdio_h.m4 (gl_STDIO_H): ...here.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog     | 4 ++++
 lib/error.h   | 3 +--
 m4/stdio_h.m4 | 5 +++--
 3 files changed, 8 insertions(+), 4 deletions(-)

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

+       stdio: limit __gnu_printf__ witness to gcc 4.4+
+       * lib/error.h (_GL_ATTRIBUTE_SPEC_PRINTF): Move gcc version probe...
+       * m4/stdio_h.m4 (gl_STDIO_H): ...here.
+
        error: use correct printf attributes on mingw
        * lib/stdio.in.h (_GL_ATTRIBUTE_SPEC_PRINTF): New define.

diff --git a/lib/error.h b/lib/error.h
index 9e594ce..eb4fb70 100644
--- a/lib/error.h
+++ b/lib/error.h
@@ -34,8 +34,7 @@
 /* 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))
+# if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
 #  define _GL_ATTRIBUTE_SPEC_PRINTF __gnu_printf__
 # else
 #  define _GL_ATTRIBUTE_SPEC_PRINTF __printf__
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index ffaf10c..f60cc21 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 45
+# stdio_h.m4 serial 46
 dnl Copyright (C) 2007-2015 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -24,7 +24,8 @@ AC_DEFUN([gl_STDIO_H],
        /* For non-mingw systems, compilation will trivially succeed.
           For mingw, compilation will succeed for older mingw (system
           printf, "I64d") and fail for newer mingw (gnu printf, "lld"). */
-       #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+       #if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) && \
+         (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
        extern char PRIdMAX_probe[sizeof PRIdMAX == sizeof "I64d" ? 1 : -1];
        #endif
       ]])], [gl_cv_func_printf_attribute_flavor=system],
-- 
2.1.0




reply via email to

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