From c26527cebbbf42ed1dbc50df0074861e0ebe33dc Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Tue, 26 May 2015 21:27:44 -0600 Subject: [PATCH] stdio: limit __gnu_printf__ witness to gcc 4.4+ 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 --- 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 6ac962272d..a5f6bd0729 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2015-05-26 Eric Blake + 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 9e594ced93..eb4fb70175 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 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 ffaf10c397..f60cc2156e 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.39.5