2 ms·
> OTOH, "int (* x)(char * )[]" is something you can call with a string and then index into to get an int. ...would be something you can call if it was a correc
by dozzie 9y ago
> OTOH, "int (* x)(char * )[]" is something you can call with a string and then index into to get an int.
...would be something you can call if it was a correct declaration. I don't
think it's valid, and certainly GCC in gnu99 mode rejects it (function
returning an array).
The rule I heard is that you start reading the declaration from the variable
name and go right to boundary (parenthesis, comma, or semicolon), then bounce
left and bounce right until all tokens were seen. Then this reads as:
int (*x[])(char *)
"x is an array <bounce-left> of pointers <bounce-right> to a function that
expects (char pointer) <bounce-right> and returns int".
- Retra 9y agoI've heard that rule too, but I've also heard it doesn't work always.