cpp/language/attributes

Introduces implementation-defined attributes for types, objects, code, etc.

Syntax
where is a comma-separated sequence of zero or more s (possibly ending with an ellipsis  indicating a )

@1@ Simple attribute, such as. @2@ Attribute with a namespace, such as. @3@ Attribute with arguments, such as. @4@ Attribute with both a namespace and an argument list.

Explanation
Attributes provide the unified standard syntax for implementation-defined language extensions, such as the GNU and IBM language extensions, Microsoft extension , etc.

An attribute can be used almost everywhere in the C++ program, and can be applied to almost everything: to types, to variables, to functions, to names, to code blocks, to entire translation units, although each particular attribute is only valid where it is permitted by the implementation: could be an attribute that can only be used with an, and not with a class declaration. could be an attribute that applies to a code block or to a loop, but not to the type, etc (note these two attributes are fictional examples, see below for the standard and some non-standard attributes).

In declarations, attributes may appear both before the whole declaration and directly after the name of the entity that is declared, in which case they are combined. In most other situations, attributes apply to the directly preceding entity.

The is a part of the attribute specifier sequence, although it has different syntax. It may appear where the attributes appear and may mix with them (provided it is used where  is permitted).

Two consecutive left square bracket tokens may only appear when introducing an attribute-specifier or inside an attribute argument.

Besides the standard attributes listed below, implementations may support arbitrary non-standard attributes with implementation-defined behavior.

Standard attributes
Only the following attributes are defined by the C++ standard.