Expert C Programming

(Jeff_L) #1

char const (*next)();


Table 3-1. Solving a Declaration Using the Precedence Rule
Rule to
apply

Explanation

A First, go to the variable name, "next", and note that it is directly enclosed by


parentheses.

B.1 So we group it with what else is in the parentheses, to get "next is a pointer to...".


B Then we go outside the parentheses, and have a choice of a prefix asterisk, or a postfix
pair of parentheses.
B.2 Rule B.2 tells us the highest precedence thing is the function parentheses at the right, so

we have "next is a pointer to a function returning..."


B.3 Then process the prefix "*" to get "pointer to".


C Finally, take the "char * const", as a constant pointer to a character.


Then put it all together to read:


"next is a pointer to a function returning a pointer to a const pointer-to-char"


and we're done. The precedence rule is what all the rules boil down to, but if you prefer something a
little more intuitive, use Figure 3-3.


Figure 3-3. How to Parse a C Declaration
Free download pdf