This is a syntax question. I came across the line:
void (*old_sigint_handler)(int);
And I have no idea what it is doing. It seems like the concatenation of three types with no variable name. I would appreciate clarification!
This is a syntax question. I came across the line:
void (*old_sigint_handler)(int);
And I have no idea what it is doing. It seems like the concatenation of three types with no variable name. I would appreciate clarification!
 
    
    Make use of cdecl to know what declaration it is exactly. It is C -> English
declare old_sigint_handler as pointer to function (int) returning void
 
    
    void (*old_sigint_handler)(int);
This defines old_sigint_handler to be a  pointer to a function which takes an int and returns void, i.e, no value. The parentheses around old_sigint_handler are necessary here else the following:
void *old_sigint_handler(int);
declares a function old_sigint_handler which takes an int and returns a pointer to void type. This is because of the precedence rules in C. Parentheses bind tightly to the indentifier old_sigint_handler than the * making it a function rather than a pointer to a function. Read this to mentally parse complex C declaration - Clockwise/Spiral Rule.
 
    
    Thats a variable declaration for the variable named old_sigint_handler, that can hold a function pointer to a function that takes an int and returns nothing (void).
 
    
    It's a declaration of a function pointer named old_sigint_handler that takes a single int and returns nothing.
 
    
    It's a declaration for a function pointer named old_sigint_handler to a function that takes an int and returns void.
