How do I understand complicated function declarations?

As others have pointed out, cdecl is the right tool for the job.

If you want to understand that kind of declaration without help from cdecl, try reading from the inside out and right to left

Taking one random example from your list char (*(*X[3])())[5];
Start at X, which is the identifier being declared/defined (and the innermost identifier):

char (*(*X[3])())[5];
         ^

X is

X[3]
 ^^^

X is an array of 3

(*X[3])
 ^                /* the parenthesis group the sub-expression */

X is an array of 3 pointers to

(*X[3])()
       ^^

X is an array of 3 pointers to function accepting an unspecified (but fixed) number of arguments

(*(*X[3])())
 ^                   /* more grouping parenthesis */

X is an array of 3 pointers to function accepting an unspecified (but fixed) number of arguments and returning a pointer

(*(*X[3])())[5]
            ^^^

X is an array of 3 pointers to function accepting an unspecified (but fixed) number of arguments and returning a pointer to an array of 5

char (*(*X[3])())[5];
^^^^                ^

X is an array of 3 pointers to function accepting an unspecified (but fixed) number of arguments and returning a pointer to an array of 5 char.

Leave a Comment