bug-gnulib
[Top][All Lists]
Advanced

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

Re: AIX xlc gets confused by logic in stdio.h


From: Bruno Haible
Subject: Re: AIX xlc gets confused by logic in stdio.h
Date: Sun, 17 Jan 2010 21:19:33 +0100
User-agent: KMail/1.9.9

Ralf Wildenhues wrote:
> It comes from test-select.o:
> $ nm -B test-select.o | grep print
>          - U .__printf__
> static void
> failed (const char *reason)
> {
>   if (++failures > 1)
>     __printf__ ("  ");
>   __printf__ ("failed (%s)\n", reason);
> }

This is as expected.

> $ nm -B ../gllib/printf.o
>         44 t .bf
>        116 t .ef
>          0 T .printf
>          - U .rpl_vfprintf
>        152 d TOC
>        160 d _$STATIC
>        176 d _$STATIC
>          - U _iob
>        156 d _iob
>        152 d printf
>        164 D printf

This should define '__printf__', not 'printf'. I guess this comes through a
'#define __printf__ printf'. Here is a proposed fix:


2010-01-17  Bruno Haible  <address@hidden>

        Avoid a link error due to the __printf__ symbol.
        * lib/stdio.in.h (__attribute__): Define to empty also for gcc 2.5.x
        and 2.6.x.
        (__format__, __printf__): Remove definitions.
        * lib/argp-fmtstream.h: Likewise.
        * lib/argp.h: Likewise.
        * lib/error.h: Likewise.
        * lib/vasnprintf.h: Likewise.
        * lib/xprintf.h: Likewise.
        * lib/xvasprintf.h: Likewise.

--- lib/argp-fmtstream.h.orig   Sun Jan 17 21:13:27 2010
+++ lib/argp-fmtstream.h        Sun Jan 17 21:11:28 2010
@@ -29,15 +29,14 @@
 #include <unistd.h>
 
 #ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#  define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || __STRICT_ANSI__
-#  define __format__ format
-#  define __printf__ printf
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The __-protected variants of the attributes 'format' and 'printf' are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+   We enable __attribute__ only if these are supported too, because
+   gnulib and libintl do '#define printf __printf__' when they override
+   the 'printf' function.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#  define __attribute__(Spec)   /* empty */
 # endif
 #endif
 
--- lib/argp.h.orig     Sun Jan 17 21:13:27 2010
+++ lib/argp.h  Sun Jan 17 21:11:28 2010
@@ -35,15 +35,14 @@
 #endif
 
 #ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#  define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || __STRICT_ANSI__
-#  define __format__ format
-#  define __printf__ printf
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The __-protected variants of the attributes 'format' and 'printf' are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+   We enable __attribute__ only if these are supported too, because
+   gnulib and libintl do '#define printf __printf__' when they override
+   the 'printf' function.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#  define __attribute__(Spec)   /* empty */
 # endif
 #endif
 
--- lib/error.h.orig    Sun Jan 17 21:13:27 2010
+++ lib/error.h Sun Jan 17 21:11:28 2010
@@ -20,15 +20,14 @@
 #define _ERROR_H 1
 
 #ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#  define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The __-protected variants of the attributes 'format' and 'printf' are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+   We enable __attribute__ only if these are supported too, because
+   gnulib and libintl do '#define printf __printf__' when they override
+   the 'printf' function.  */
 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __format__ format
-#  define __printf__ printf
+#  define __attribute__(Spec)   /* empty */
 # endif
 #endif
 
--- lib/stdio.in.h.orig Sun Jan 17 21:13:27 2010
+++ lib/stdio.in.h      Sun Jan 17 21:11:28 2010
@@ -45,15 +45,14 @@
 #include <sys/types.h>
 
 #ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#  define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The __-protected variants of the attributes 'format' and 'printf' are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+   We enable __attribute__ only if these are supported too, because
+   gnulib and libintl do '#define printf __printf__' when they override
+   the 'printf' function.  */
 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __format__ format
-#  define __printf__ printf
+#  define __attribute__(Spec)   /* empty */
 # endif
 #endif
 
--- lib/vasnprintf.h.orig       Sun Jan 17 21:13:27 2010
+++ lib/vasnprintf.h    Sun Jan 17 21:11:28 2010
@@ -25,15 +25,14 @@
 #include <stddef.h>
 
 #ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#  define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The __-protected variants of the attributes 'format' and 'printf' are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+   We enable __attribute__ only if these are supported too, because
+   gnulib and libintl do '#define printf __printf__' when they override
+   the 'printf' function.  */
 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __format__ format
-#  define __printf__ printf
+#  define __attribute__(Spec)   /* empty */
 # endif
 #endif
 
--- lib/xprintf.h.orig  Sun Jan 17 21:13:27 2010
+++ lib/xprintf.h       Sun Jan 17 21:11:28 2010
@@ -21,15 +21,14 @@
 #include <stdio.h>
 
 #ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#  define __attribute__(Spec)   /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The __-protected variants of the attributes 'format' and 'printf' are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+   We enable __attribute__ only if these are supported too, because
+   gnulib and libintl do '#define printf __printf__' when they override
+   the 'printf' function.  */
 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __format__ format
-#  define __printf__ printf
+#  define __attribute__(Spec)   /* empty */
 # endif
 #endif
 
--- lib/xvasprintf.h.orig       Sun Jan 17 21:13:27 2010
+++ lib/xvasprintf.h    Sun Jan 17 21:11:28 2010
@@ -21,15 +21,14 @@
 #include <stdarg.h>
 
 #ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#  define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
-   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The __-protected variants of the attributes 'format' and 'printf' are
+   accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+   We enable __attribute__ only if these are supported too, because
+   gnulib and libintl do '#define printf __printf__' when they override
+   the 'printf' function.  */
 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __format__ format
-#  define __printf__ printf
+#  define __attribute__(Spec)   /* empty */
 # endif
 #endif
 




reply via email to

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