HELPLIB.HLB  —  CC  Language topics, Declarations
  Declarations specify the functions and variables referenced in a
  program.  Declarations in C have the following syntax:

        declaration:

           declaration-specifiers [init-declarator-list];

        declaration-specifiers:

           storage-class-specifier [declaration-specifiers]
           type-specifier [declaration-specifiers]
           type-qualifier [declaration-specifiers]

        init-declarator-list:

           init-declarator
           init-declarator-list, init-declarator

        init-declarator:

           declarator
           declarator = initializer

  Note the following items about the general syntax of a declaration:

   o  The storage-class-specifier, type-qualifier, and type-specifier
      can be listed in any order.  All are optional, but, except for
      function declarations, at least one such specifier or qualifier
      must be present.  Placing the storage-class-specifier anywhere
      but at the beginning of the declaration is an obsolete style.

   o  Storage-class keywords are auto, static, extern, and register.

   o  Type qualifiers are const, volatile, __restrict, and
      __unaligned.

   o  The declarator is the name of the object being declared.  A
      declarator can be as simple as a single identifier, or can be a
      complex construction declaring an array, structure, pointer,
      union, or function (such as *x, tree(), and treebar[10]).

   o  Initializers are optional and provide the initial value of an
      object.  An initializer can be a single value or a
      brace-enclosed list of values, depending on the type of object
      being declared.

   o  A declaration determines the beginning of an identifier's
      scope.

   o  An identifier's linkage is determined by the declaration's
      placement and its specified storage class.

  Consider the following example:

       volatile static int var_number = 10;

 This declaration shows a qualified type (a type, int, with a type
 qualifier, volatile), a storage class (static), a declarator (data),
 and an initializer (10).  This declaration is also a definition,
 because storage is reserved for the data object var_number.

 For more information, see HELP CC LANGUAGE_TOPICS DATA_TYPES, HELP
 CC LANGUAGE_TOPICS STORAGE_CLASSES, and HELP CC LANGUAGE_TOPICS
 TYPE_QUALIFIERS.

1  –  Interpretation

  The symbols used in declarations are C operators, subject to the
  usual rules of precedence and associativity.  These operators are
  parentheses, brackets, and asterisks for "function returning...",
  "array of...", and "pointer to...", respectively.  Parentheses and
  brackets associate left to right; asterisk operators associate
  right to left.  Parentheses and brackets have the same precedence,
  which is higher than that of asterisks.  Parentheses are also used
  to change the associativity of the other operators.

  The following declaration, for example, is a "function returning a
  pointer to an array of pointers to char":

         char * ( *x() ) [];

  This is how the declaration is broken down to determine what it is:

         char * ( *x() ) [];

              * ( *x() ) [] is char
                ( *x() ) [] is (pointer to) char
                  *x()      is (array of) (pointer to) char
                   x()      is (pointer to) (array of) (pointer to)
                                char
                   x        is (function returning) (pointer to)
                               (array of) (pointer to) char

  In this sort of breakdown, lower precedence operators are removed
  first.  With two equal precedence operators, remove the rightmost
  if they are left-to-right operators, and the leftmost if they are
  right-to-left operators.  For example, "[]()" means "array of
  functions returning...".
Close Help