I just finished reading the link to the language (Appendix A) of the second edition of K & R's "C Programming Language" for the new assignment.
Please note that I have developed how to read C declarations with all the directions here on SO (so thanks;)). The explanation has always been a reference to the priority of expressions and operators in C.
I can conclude the same priority table from the aka Appendix A, & A7 reference manual in the specified book, no problem.
However, section A7 deals with the priority of expression operators, as stated at the beginning of the section - postfix-expression [ expression ] square brackets are treated as an index operator, asterisk * considered as an indirect operator and parentheses ( argument-expression-list) or () refer to function calls, see & A7.3.
So, why do so many people refer to this priority table when the subject is C declarations and even gets a pair of upvotes on SO? The only priority that he claims to determine is certain expression operators.
How ads should be analyzed is written in & sect; A8, especially & sect; A8.6 goes into the basics of more complex announcements.
But throughout Appendix A, there are no claims about the priority in which parentheses, square brackets, asterisks, type names, etc. should be copied.
On page 216 it says that parentheses can change the binding of complex declarators, but now how (although I have a hunch, see below in my example).
Let me give an example in "pseudo-code", where I am at a loss, using & sect; A8.8 (designation T for type specifiers, D for declarators):
Reading declaration C:
Original declaration: char (*(*f())[])() Now let T=char , D=(*(*f())[])() D=D1(), where D1=(*(*f())[]) The type of f, according to A8.6.3 is then :L1 f is "type-modifiers of f in D1" function returning char Now look at T D1 = char (*(*f())[]) :ALT_A The type of f in D1 = (*(*f())[]) is the same as that of f in D2=*(*f())[] Looking at D2 = T1 D3[] ----> have to use A8.6.2, where T1 = * , D3 = (*f()), so the type of f in T1 D3 is f is "type-modifiers of f in D3" array of pointers () look at f in D3 = (*f()), or equivalently, f in D4 = *f(). Have to use A8.6.3. ---> f is a function returning a pointer to () going up a level: f is "type-modifiers of f in D3" array of pointers () translates to: f is a function returning a pointer to an array of pointers () going up another level: f is "type-modifiers of f in D1" function returning char translates to: f is a function returning a pointer to an array of pointers to functions returning a char
This result also shows cdecl. Please note that I did not use the priority table, just a reference guide and sections specifically related to announcements.
So, how and why do so many people refer to operator priority?
It seems to me that every reference to operator precedence, when people ask about C declarations, is the wrong answer giving a "parsing algorithm" that magically gives the correct result.
And secondly, how did it happen that K & R seems so inaccurate with many things (see my / * * / comments in the pseudo-code)? I would expect more accuracy, I mean that they obviously knew all the details and should have been able to think accurately.
Sorry for the messy formatting, by the way. I spent most of this day trying to write down how I manually parse this and at the same time understand what K & R could mean with this and that wording ...
List of sources in which advertisements and operator priority are announced:
http://users.ece.utexas.edu/~ryerraballi/CPrimer/CDeclPrimer.html ("Everyone must understand any complex C declaration, in order to know that these declarations are based on the priority diagram of the C operator, the same one you use to evaluate expressions in C: ")
http://binglongx.com/2009/01/25/how-to-read-a-cc-declaration/
How are (complex) ads analyzed in terms of priority and associativity? (โIn fact, C designers were wise enough for ads to use the sameโ precedence rules โas expressions. This is anโ ad follows use โrule. For example, in the expression, see Brianโs first answer).
Operator Priority in C Definitions
Expert Programming C: Deep C Secrets, p. 74, 28 5 reviews for reviews on Google Books?