Why does GCC’s __attribute__((…)) syntax use double parentheses?

To make it easier to eliminate it for different compiler. If you have portable code, you have to remove them for other compilers, so you do

#ifndef __GNUC__
#define __attribute__(x)
#endif

The problem is that attributes have various number of arguments and you can combine multiple attributes in one __attribute__ declaration, but C only introduced variadic macros in C99. With double parenthesis the above definition does not need variadic macros.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)