xproto: _X_NONNULL uses GNU extension
Thomas Klausner
wiz at NetBSD.org
Sat Jan 10 15:41:29 PST 2015
On Fri, Jan 09, 2015 at 03:26:24PM -0800, Alan Coopersmith wrote:
> On 01/ 9/15 02:53 PM, Thomas Klausner wrote:
> >Hi!
> >
> >When compiling slock with clang, one sees:
> >
> >/scratch/x11/slock/work/.buildlink/include/X11/Xfuncproto.h:157:24: warning: named variadic macros are a GNU extension [-Wvariadic-macros]
> >#define _X_NONNULL(args...) __attribute__((nonnull(args)))
> >
> >Is there a way to define this without using GNU extensions?
>
> You could use C99 varargs macros like the non-#if __GNUC__ case does,
> we just never bothered making the __GNUC__ version portable to non-gcc
> compilers, since why lie and say you're gcc compatible if you're not?
I think the idea is that in wide areas clang really is gcc-compatible,
but prefers to follow C99 or C++11 if it conflicts.
Would the attached patch be acceptable? That at least removes the
warning for clang for me.
Cheers,
Thomas
-------------- next part --------------
>From 3e19da43d5cc70c4a848f8d95d324e884426532b Mon Sep 17 00:00:00 2001
From: Thomas Klausner <wiz at NetBSD.org>
Date: Sun, 11 Jan 2015 00:39:14 +0100
Subject: [PATCH:xproto] Use C99 compliant definition of nonnull attribute.
Fixes warning with clang.
Signed-off-by: Thomas Klausner <wiz at NetBSD.org>
---
Xfuncproto.h.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Xfuncproto.h.in b/Xfuncproto.h.in
index e9e5e71..5daa83e 100644
--- a/Xfuncproto.h.in
+++ b/Xfuncproto.h.in
@@ -152,6 +152,9 @@ in this Software without prior written authorization from The Open Group.
argument macros, must be only used inside #ifdef _X_NONNULL guards, as
many legacy X clients are compiled in C89 mode still. */
#if __has_attribute(nonnull) \
+ && defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */
+#define _X_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
+#elif __has_attribute(nonnull) \
|| defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
#define _X_NONNULL(args...) __attribute__((nonnull(args)))
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */
--
2.2.1
More information about the xorg-devel
mailing list