void (*signal(int sig, void (*func)(int)))(int);
void (*)(int)
type pointer to (function with one int parameter returning void)
*signal()
signal is a function returning pointer
(Note:
(*signal)()
would mean: signal is a pointer to function)
void (*signal())(int);
signal is a function returning pointer to (function with one int
param returning void)
void (*signal(int sig, void (*func)(int)))(int);
signal is a function with two parameters, returning pointer etc...
The first parameter is type int, the second parameter is type:
void (*)(int)
ie. pointer to function with one int parameter returning void.
The original declaration is equivalent to:
void (*signal(int, void (*)(int)))(int);
ie. the parameters of `signal' don't have to be named, similarly
parameter to `func' was not named.
Note that the type of the second parameter of `signal' is the same
as the type that `signal' returns, ie. "pointer to (fn with one int
param, returning void)".
It's easier to understand if you declare a type:
typedef void (*ptr_void_fn_int)(int);
ptr_void_fn_int signal(int, ptr_void_fn_int);
(ptr_void_fn_int is type "pointer to (fn with one etc...)").
`signal' function for a given signal number sets the new signal
handler you supply (which is type ptr_void_fn_int) and returns
you the previous handler (which naturally has to be the same type).
(For exact `signal' semantics see N869 7.14.1.1.)
void interrupt ( *oldhandler)();
-If it's a right prototype, what does identifier "interrupt" mean? Will
it be a type qualifier.
`interrupt' is not an ISO C keyword. It probably denotes function
call convention, and means that the function `oldhandler' points to
will be called from outside as an interrupt handler (but I might be
very wrong here). You have to consult your compiler manual.