Search code examples
c++cgccgcc-warning

The difference between __attribute__((unused)) and __attribute((unused)) in GCC


__attribute__((unused)) and __attribute((unused)) can mark variables as unused to avoid unused warning.

What is the difference between them?


Solution

  • In the GCC repository, in the file c-common.c, the array c_common_reswords of the type struct c_common_resword is defined.

    In the array, you will find the following elements:

     { "__attribute",   RID_ATTRIBUTE,  0 },
     { "__attribute__", RID_ATTRIBUTE,  0 },
    

    And RID_ATTRIBUTE is defined in c-common.h in the enum rid in the /* C extensions */ section.

    So __attribute and __attribute__ are the same.