[xproto] _X_NONNULL and C++ 11

Matthieu Herrb matthieu at herrb.eu
Sat May 27 09:02:44 UTC 2017


Hi,

Marc Espie recently found out that the X_NONNULL macro in Xfuncproto.h
is generating spurious warnings when included in C++ code build with
clang++ -std=c++11.

Other OpenBSD developper tried to find uses of the macro in the wild
and didn't find any, even in the X.Org lib app or xserver tree.

So, should this macro definition be removed alltogether (acking that
no-one cares to use it) or just apply the patch below ?

From 6ae956660879d70e078025c3d8f1ac3fd438cad2 Mon Sep 17 00:00:00 2001
From: Marc Espie <espie at nerim.net>
Date: Sat, 27 May 2017 10:55:04 +0200
Subject: [PATCH] Fix compiling any C++ code including Xfuncproto.h with
 clang++ -std=c++11

It shouldn't warn, bu it will use the "legacy" varargs macros and whine.
---
 Xfuncproto.h.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Xfuncproto.h.in b/Xfuncproto.h.in
index b88493d..1be3f55 100644
--- a/Xfuncproto.h.in
+++ b/Xfuncproto.h.in
@@ -166,7 +166,8 @@ 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 */
+    && (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) \
+    || (defined(__cplusplus) && (__cplusplus - 0 >= 201103L))) /* C99 C++11 */
 #define _X_NONNULL(...)  __attribute__((nonnull(__VA_ARGS__)))
 #elif __has_attribute(nonnull) \
     || defined(__GNUC__) &&  ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
-- 
2.13.0


-- 
Matthieu Herrb
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 793 bytes
Desc: not available
URL: <https://lists.x.org/archives/xorg-devel/attachments/20170527/7dab0c9b/attachment-0001.sig>


More information about the xorg-devel mailing list