Monday, December 6, 2010

Complex Type Declarations

The following declaration:typedef int(*(* (func()) )[]); means: func is a function returning a pointer to an array of pointers to integers.

I first saw the rule in the paper:

"This Simple "Clockwise" Rule Helps Decipher Complex Declarations", by Andrew Binstock in "The C User's Group Newsletter", June 1987 issue.

The only reference I found to it on the Web was:

The rule applies only when C constructs are used in a declaration and not C++.

Basically, you start with the symbol you are defining, go to the right in a clockwise manner. Read off what you see. You need to obey any parentheses.

No comments:

Post a Comment