In C all function calls take place via a function pointer. It says so in section 18.104.22.168: “Constraints: The expression that denotes the called function shall have type pointer to function returning void or returning an object type other than an array type.”.
So what happens when you write
p = malloc(sizeof *p);?
malloc isn’t a function pointer, it’s a function. What happens is that when a function is used in an expression it is automatically converted to a pointer to the function instead (section 22.214.171.124); except for
sizeof where it is illegal, and
That means that if
callback is already a function pointer you don’t need to go
(*callback)() to call it, you can just go
callback(). Most of the time I prefer that. It’s neater because you don’t need the
* so you don’t need the parentheses either. It also shows confidence; it shows that you know what you’re doing.
If do you go
(*callback)() then dereferencing the pointer yields a function, which is automatically converted back into the function pointer. It all seems a bit pointless. An amusing consequence, which not that many C programmers seem to realise, is that you can have as many
*s as you like: