[PATCH:x11proto] Enable gcc attribute(__format__) on gcc versions older than 4.0

Alan Coopersmith alan.coopersmith at oracle.com
Thu Dec 9 22:34:01 PST 2010


Enabled on 2.3 and up, since that's where it's available according to
http://www.ohse.de/uwe/articles/gcc-attributes.html#func-format

Tested with gcc 3.4.3 on Solaris.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 Xfuncproto.h.in |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Xfuncproto.h.in b/Xfuncproto.h.in
index 0177119..b624956 100644
--- a/Xfuncproto.h.in
+++ b/Xfuncproto.h.in
@@ -77,10 +77,8 @@ in this Software without prior written authorization from The Open Group.
 
 #if defined(__GNUC__) && (__GNUC__ >= 4)
 # define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))
-# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
 #else
 # define _X_SENTINEL(x)
-# define _X_ATTRIBUTE_PRINTF(x,y)
 #endif /* GNUC >= 4 */
 
 #if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__)
@@ -124,4 +122,10 @@ in this Software without prior written authorization from The Open Group.
 # define _X_NORETURN
 #endif /* GNUC  */
 
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
+# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
+#else /* not gcc >= 2.3 */
+# define _X_ATTRIBUTE_PRINTF(x,y)
+#endif
+
 #endif /* _XFUNCPROTO_H_ */
-- 
1.7.3.2



More information about the xorg-devel mailing list