Firstly, I am new to C++ on Linux (touching C/C++/Linux after almost 20 years), so apologies for being naive.
I saw the use of signal
function in the source for showkey
program here and went on searching for how this works. I understood how this works, but it is the declaration of signal function that I am unable to understand.
This Page says that the signal
function is defined as
void (*signal(int sig, void (*func)(int)))(int)
In this, I understood
- return type is
void
- first parameter is
int
type - second parameter is a pointer to function that accepts an
int
parameter and returns avoid
What I am unable to understand is:
- bracket after void and before star * (in the very beginning) why this ordering of brackets?
- why
signal
method name is presented as pointer (*signal(...)? - what does the
(int)
in the end means?
Can anyone please help me understand this. If there is any reference to this advanced level of C pointer usage that will be much beneficial for my overall understanding and learning.
TIA.