Re:How Do I Declare a Function Pointer in C?
by hzhou321 on Friday January 20, 2017 @09:30AM
(#13443970)
What we need realize is that simple grammar does not always lead to simple comprehension. Nesting the grammar elements more than a few levels is always difficult for our current biology equipment.
Re:How Do I Declare a Function Pointer in C?
by nialv7 on Friday January 20, 2017 @07:18PM
(#13448031)
You define a variable the same way you would use it.
int *a -> expression *a has type int.
int *a[10] -> *a[_] has type int.
int (*a)[10] -> (*a)[_] has type int.
int (*a)(int, int) -> (*a)(_, _) has type int.
No need for complicated things like "spiral rules", etc.
Re:How Do I Declare a Function Pointer in C?
by bnmfsd on Friday January 20, 2017 @08:24AM
(#13443593)
Stackoverflow related question/answer: http://stackoverflow.com/a/34548829/1119701
The apparent struggle I see with this syntax has always somewhat puzzled me, because I don't see the same level of complaints about e.g. arithmetic expressions (like 6+3*4/(2+1)) which are parsed with precedence in much the same way. K&R even has a section on writing a parser that recognises this syntax, so I suspect it's really not that hard, but the perception spread by those who didn't learn the syntax but only memorised the "easy cases" is making it appear more difficult than it really is.