Spiral rule and 'declaration follows usage' for parsing C and C++ declarations
You just have to build it up in steps.
char *X(); // X =~ (*(*a[N])())
Function returning char*
char *(*Y())(); // Y =~ (*a[N])
Function returning pointer to function returning char*
.
In a declaration, just as in an expression (declaration follow usage), postfix []
has a higher precedence that unary *
so *a[N]
is equivalent to *(a[N])
, not (*a)[N]
.
char *(*(*Z)())(); // Z =~ a[N]
Pointer to function returning pointer to function returning char*
.
char *(*(*a[N])())();
Array of N pointers to functions returning a pointer to function returning char*
.