[dcl.spec.general] (original) (raw)

9 Declarations [dcl]

9.2 Specifiers [dcl.spec]

9.2.1 General [dcl.spec.general]

The specifiers that can be used in a declaration are

The attribute-specifier-seqaffects the type only for the declaration it appears in, not other declarations involving the same type.

At most one of each of the decl-specifiers friend, typedef, or inlineshall appear in a decl-specifier-seq.

At most one of the constexpr, consteval, and constinit keywords shall appear in a decl-specifier-seq.

The sequence shall be self-consistent as described below.

[Example 1: typedef char* Pc;static Pc;

Here, the declaration static Pc is ill-formed because no name was specified for the static variable of type Pc.

To get a variable called Pc, a type-specifier (other thanconst or volatile) has to be present to indicate that the typedef-name Pc is the name being (re)declared, rather than being part of the decl-specifier sequence.

For another example,void f(const Pc); void g(const int Pc);

— _end example_]

[Note 1:

Since signed, unsigned, long, and shortby default imply int, a type-name appearing after one of those specifiers is treated as the name being (re)declared.

[Example 2: void h(unsigned Pc); void k(unsigned int Pc); — _end example_]

— _end note_]