1 /* Macro voodoo rewriting GCC-style attributes to C23-style attributes. */
2 /* Can be used via "--include gcc_attr.h" on the command line. */
4 #if __STDC_VERSION__ < 202311L
6 /* Not in C23 mode => remove GCC-style attributes */
7 #warning "Rewriting GCC-style to C23-style attributes requires C23. Ignoring all GCC-style attributes."
8 #define __attribute__(__GCC_ATTR_ARG)
12 /* In C23 mode => translate to C23-style attributes */
13 /* e.g. from __attribute__((packed, foo(bar))) to [[packed, foo(bar)]] */
14 #warning "Rewriting GCC-style to C23-style attributes. Please check compatibility."
15 #define __GCC_ATTR_LIST_ARGS(...) __VA_ARGS__
16 #define __GCC_ATTR_UNWRAP_ARG(__GCC_ATTR_ARG) __GCC_ATTR_ARG
17 #define __attribute__(__GCC_ATTR_ARG) [[__GCC_ATTR_UNWRAP_ARG(__GCC_ATTR_LIST_ARGS __GCC_ATTR_ARG)]]