Overview of declarators

A declarator declares an object, function, or C++referenceC++ as part of a declaration.

A declarator has the following form:

Read syntax diagramSkip visual syntax diagram
Declarator syntax (C only)

|--+----------------------+--direct_declarator------------------|
   | .------------------. |                      
   | V                  | |                      
   '---pointer_operator-+-'                      

Read syntax diagramSkip visual syntax diagram
Declarator syntax (C++ only)

|--+-+----------------------+--direct_declarator-+--------------|
   | | .------------------. |                    |   
   | | V                  | |                    |   
   | '---pointer_operator-+-'                    |   
   |                      (1)                    |   
   '-trailing_return_type------------------------'   

Notes:
  1. C++11
Read syntax diagramSkip visual syntax diagram
Direct declarator

|--+-declarator_name-----------------------------------+--------|
   +-function_declarator-------------------------------+   
   +-direct_declarator--[--+---------------------+--]--+   
   |                       '-constant_expression-'     |   
   '-(--+----------------------+--direct_declarator--)-'   
        | .------------------. |                           
        | V                  | |                           
        '---pointer_operator-+-'                           

Read syntax diagramSkip visual syntax diagram
Pointer operator (C only)

|--*--+--------------------+------------------------------------|
      '-type_qualifier_seq-'   

Read syntax diagramSkip visual syntax diagram
Declarator name (C only)

|--identifier_expression----------------------------------------|

Read syntax diagramSkip visual syntax diagram
Pointer operator (C++ only)

|--+-*--+--------------------+--------------------------------+--|
   |    '-type_qualifier_seq-'                                |   
   +-&--------------------------------------------------------+   
   |    (1)                                                   |   
   +-&&-------------------------------------------------------+   
   '-+----+--nested_name_specifier--*--+--------------------+-'   
     '-::-'                            '-type_qualifier_seq-'     

Notes:
  1. C++11
Read syntax diagramSkip visual syntax diagram
Declarator name (C++ only)

|--+----------------------------------------------+-------------|
   +-identifier_expression------------------------+   
   '-+----+--+-----------------------+--type_name-'   
     '-::-'  '-nested_name_specifier-'                

Notes:
  • The type_qualifier_seq represents one or a combination of type qualifiers. For the details of type qualifiers, see Type qualifiers.
  • C++ onlyA nested_name_specifier is a qualified identifier expression. An identifier_expression can be a qualified or unqualified identifier.C++ only

For the details of function declarators, see Function declarators.C++11For the details of trailing return types, see Trailing return type (C++11).C++11

The following types are known as derived declarator types, and are therefore discussed in this section:

IBM extensionIn addition, for compatibility with GNU C and C++, XL C/C++ allows you to use variable attributes to modify the properties of data objects. As they are normally specified as part of the declarator in a declaration, they are described in Variable attributes (IBM extension).IBM extension