summaryrefslogtreecommitdiff
path: root/Xfuncproto.h.in
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-08-26 13:55:29 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-08-30 16:29:29 -0700
commitc270f8bed465daff386967c5586eb3c8490b86e0 (patch)
tree4dcc4da8078f3c2a46791405b5037fd934059e1c /Xfuncproto.h.in
parent06ebd5b88bee8c54222bde3178dc773776036802 (diff)
Fix Xfuncproto.h to work when #included in a C89-mode compilation
Variable argument macros are not supported in C89, only C99 or a compiler-specific extension like gcc's. Even just defining the macro causes builds with C89 compilers to fail, as they can't figure out how to handle #define _X_NONNULL(...), so only define the fallback for C99 compilers. Since this means C89 compilers will see _X_NONNULL unexpanded in sources, add a comment to remind users that this should only be used with #ifdef _X_NONNULL guards in public/exported API headers we install for other software to compile against, so that we don't break their builds. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Julien Cristau <jcristau@debian.org>
Diffstat (limited to 'Xfuncproto.h.in')
-rw-r--r--Xfuncproto.h.in6
1 files changed, 4 insertions, 2 deletions
diff --git a/Xfuncproto.h.in b/Xfuncproto.h.in
index 0d7b8b7..dc913fa 100644
--- a/Xfuncproto.h.in
+++ b/Xfuncproto.h.in
@@ -128,10 +128,12 @@ in this Software without prior written authorization from The Open Group.
# define _X_ATTRIBUTE_PRINTF(x,y)
#endif
-/* requires xproto >= 7.0.22 */
+/* requires xproto >= 7.0.22 - since this uses either gcc or C99 variable
+ argument macros, must be only used inside #ifdef _X_NONNULL guards, as
+ many legacy X clients are compiled in C89 mode still. */
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
#define _X_NONNULL(args...) __attribute__((nonnull(args)))
-#else
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */
#define _X_NONNULL(...) /* */
#endif