Q: How do I decipher the declaration: void *((*fnp[4])())(); ?
We can apply the philosophy of declarations (discussed in the Section
http://geocities.com/vijoeyz/articles/c/pna/pna2.html#7.4) to decipher this
declaration. Following are the steps used to deduce that fnp is an array four
of pointers to functions, which take unspecified parameters and returns pointer
to a function, which takes unspecified parameters and returns pointer to void *!
1. Array subscript operators ([]) bind tightly than the indirection operator (*)
2. fnp, therefore, is an array
3. Since fnp[4] is surrounded between (* and ), it has type pointer to. Thus,
in the expression (*fnp[4]), fnp has the type array four of pointer to
4. After having its meaning understood, substitute (*fnp[4]) with X, so the
declaration trims down to void *(X())();
5. Compare the new declaration with a simple declaration like int *p();
(function p returns a pointer to an int). Similarly, X is a function, which
returns a pointer to something. That something is (), a function
6. To decide the return type of X, we follow a simple philosophy of C that - in
a declaration like int *p;, the data type of p can be established by deleting
p from the declaration. So int * (pointer to int) is the type of p
7. Hence, after deleting (X()) from void *(X())();, we find that the return type
of (X()) is void *(), that is, a function returning a pointer to void. Since
a function name is interpreted as a pointer to that function, the return type
of (X()) is actually a pointer to function returning void *
8. Substituting the value of X in the step 7 leads to the fact that
((*fnp[4])()) returns void *()
9. Hence, fnp is an array four of pointers to a function, which takes
unspecified parameters and returns pointer to a function, which also takes
unspecified parameters and returns pointer to void *.
               (
geocities.com/vijoeyz/faq)                   (
geocities.com/vijoeyz)