VMS Help
CC, Language topics, Declarations, Interpretation

 *Conan The Librarian (sorry for the slow response - running on an old VAX)

  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     HLB-list     TLB-list     Help  

[legal] [privacy] [GNU] [policy] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.