Standard rule: find the leftmost identifier, then work your way out remembering that function-call ()
and []
bind before *
, so *a[]
is an array of pointers, (*a)[]
is a pointer to an array, *f()
is a function returning a pointer, and (*f)()
is a pointer to a function. Apply this rule recursively for any function parameters.
With all that in mind, the declaration breaks down like so:
signal -- signal
signal( ) -- is a function taking
signal(int, ) -- an int parameter and
signal(int, fp ) -- a parameter named fp of type
signal(int, (*fp) ) -- pointer to
signal(int, (*fp)( )) -- function taking
signal(int, (*fp)(int)) -- an int parameter
signal(int, void (*fp)(int)) -- returning void
(*signal(int, void (*fp)(int))) -- returning a pointer to
(*signal(int, void (*fp)(int)))( ) -- a function taking
(*signal(int, void (*fp)(int)))(int) -- an int parameter
void (*signal(int, void (*fp)(int)))(int); -- returning void
So, signal
takes two arguments, one of which is a pointer to a function taking an int and returning void, and returns a pointer to a function of the same type as fp
.