Use spiral rule (reading inside out clockwise) to understand the syntax:
Find the identifier
void (*signal(int signo, void (*func)(int)))(int);
^ ^
| |
+----+
|
Identifier name
signal
is a ....
Move right
void (*signal(int signo, void (*func)(int)))(int);
^ ^
| |
+----------------------------+
|
arguments (so, its a function)
signal
is a function which accepts int
and void (*) (int)
[pointer to a function which accepts a int
argument and returns nothing (void
)] as arguments ....
Can't move right anymore because of the right parenthesis, so move left.
void (*signal(int signo, void (*func)(int)))(int);
^
|
pointer
signal
is a function which accepts int
and void (*) (int)
as arguments and returns a pointer ....
Can't move left anymore because of the left parenthesis, so keep going right.
void (*signal(int signo, void (*func)(int)))(int);
^ ^
| |
+---+
|
argument
(which means signal() is returning a function pointer)
signal
is a function which accepts int
and void (*) (int)
as arguments and returns a pointer to a function which accepts a int
argument and ....
Can't move right anymore because we're out of symbols, so go left.
void (*signal(int signo, void (*func)(int)))(int);
^ ^
| |
+--+
|
return type of function whose pointer returned by signal() function
signal
is a function which accepts int
and void (*) (int)
as arguments and returns a pointer to function which accepts a int
argument and returns nothing (void
).