For convenience, from now on a function that takes and returns nothing shall be called a "routine".
both (*set_new_handler (XXX))(); and void(*)() declarations are same. |
Uh... No.
(*set_new_handler (XXX))();
is not a declaration. It's nothing; it's not syntactically valid.
void (*set_new_handler (XXX))();
does return a pointer.
Now, this last valid declaration of set_new_handler is
not the same as
void(*)()
. A
void(*)()
is a pointer to a routine.
--------------------------------------------------------------------------------
Look, this is what's going on:
A function pointer is declared as return_type (*optional_identifier)(parameter_list). A pointer to a routine is:
typedef void (*routine_pointer)();
set_new_handler's declaration is equivalent to this:
routine_pointer set_new_handler(routine_pointer);
The typedef above can be replaced with a macro:
#define ROUTINE_POINTER(id) void (*id)()
Then the declaration can be written as
ROUTINE_POINTER(set_new_handler(ROUTINE_POINTER()))
--------------------------------------------------------------------------------
Try to expand that last line of code and I think you'll understand what's going on.