Next: Statement Attributes, Previous: Label Attributes, Up: C Extensions [Contents][Index]

### 6.35 Enumerator Attributes

GCC allows attributes to be set on enumerators. See Attribute Syntax, for details of the exact syntax for using attributes. Other attributes are available for functions (see Function Attributes), variables (see Variable Attributes), labels (see Label Attributes), statements (see Statement Attributes), and for types (see Type Attributes).

This example uses the `deprecated` enumerator attribute to indicate the `oldval` enumerator is deprecated:

    enum E {
      oldval __attribute__((deprecated)),
      newval
    };

    int
    fn (void)
    {
      return oldval;
    }

`deprecated`

  The `deprecated` attribute results in a warning if the enumerator is used anywhere in the source file. This is useful when identifying enumerators that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated enumerator, to enable users to easily find further information about why the enumerator is deprecated, or what they should do instead. Note that the warnings only occurs for uses.