5 ms·
In C, the easiest thing to do is to just use a typedef. You get to use the same syntax as for normal function calls with no trying to remember where that blaste
by david-given 10y ago
In C, the easiest thing to do is to just use a typedef. You get to use the same syntax as for normal function calls with no trying to remember where that blasted extra * goes, and typically end up with cleaner code anyway.
typedef void function_ptr_t(int i);
function_ptr_t* ptr;
- bstamour 10y agoYeah, typedefs solve the problem for fixed types. I guess you could use a macro to create a generic FUNC_PTR or something as well.
- ramshorns 10y agoMacros are often a bad idea for defining types. If you do #define INT_PTR int* INT_PTR p, q; the code is actively misleading. Is there a better way to do it for function pointers?
- flukus 10y agoThere are a few other problems with multiple declarations aren't there? I though they were discouraged in c.