Richard Heathfield said:
Keith Thompson said:
Oops, nice catch. Thanks, Keith. The corresponding C89 quote is in
3.7.1, with the same wording, modulo the capital A and the
cross-ref.
If it helps reduce the surprise factor, this is somewhat analogous to
the treatment of parameters that look as if they have an array type.
I too, only came across this very recently due to a typo and a
preference for keeping *s out of typedefs. I'd written:
typedef int func(int);
int some_function(func f) /* forgot the * by accident! */
{...}
and only found out that I should have been surprised that it worked
some time later when fixing something else! On the other hand, I
would not have been surprised that
typedef int vector[3];
int other_function(vector v) {...}
makes 'other_function' of type 'int(int *)' so there is some
similarity. Of course, the similarity stops when you *do* add the *.
It has no effect on 'some_function' but changes the type of
'other_function' to be 'int(int (*)[3])'.