Variadic macros in installed headers
Florian Weimer
fw@deneb.enyo.de
Sat Nov 23 13:43:00 GMT 2019
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.
More information about the Libc-alpha
mailing list