This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Variadic macros in installed headers
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Martin Sebor <msebor at gmail dot com>, libc-alpha at sourceware dot org
- Date: Sat, 23 Nov 2019 14:43:39 +0100
- Subject: Variadic macros in installed headers
This is about bug 25219, which proposes this patch:
+#if __GNUC_PREREQ (10, 0)
+/* Denotes a function pointer argument can be used to access an array
+ of N elements according to access mode. */
+# define __rdonly(...) \
+ __attribute__ ((__access__ (__read_only__, __VA_ARGS__)))
+# define __rdwr(...) \
+ __attribute__ ((__access__ (__read_write__, __VA_ARGS__)))
+# define __wronly(...) \
+ __attribute__ ((__access__ (__write_only__, __VA_ARGS__)))
+#else
+# define __rdonly(...)
+# define __rdwr(...)
+# define __wronly(...)
+#endif
This makes the relevant headers incompatible with C89. I think the
attribute definition either needs to be changed to require parenthesis
around the arguments (similar to __atribute__ itself), or we need to
use multiple macro definitions for each access mode.
I also dislike that the attribute does not use symbolic expressions.
It means that it cannot be used to annotate functions like asctime_r
directly. C++-like pointer-pairs also need auxiliary function
definitions.