The style
typedef void func_t (void);
...
funct_t* fp;
Is one of the clearest ways to declare function pointers. Clear because it is consistent with the rest of the pointer syntax of C.
It is equivalent to the slightly less readable
typedef void (*func_t)(void);
func_t fp;
Which in turn is equivalent to the much less readable
void (*fp)(void);
The advantage of the first style becomes obvious when you pass these as parameters to a function:
1) void sort (func_t* callback); // very clear and readable!
2) void sort (func_t callback); // hmm what is this? passing by value?
3) void sort (void(*callback)(void)); // unreadable mess
Generally, it is a bad idea to hide the pointer syntax behind typedefs. Function pointers are no exception.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…