Instead of declaring a function pointer typedef for a function, is it possible to get it from a function declaration?
Usually,
int foo(int x); typedef int (*fooFunc)(int); fooFunc aFunc;
What I want:
int foo(int x); foo* aFunc;
I want to use it for dlsym:
foo* aFunc; aFunc = dlsym(lib, "foo"); aFunc(x);
If I update foo and forgot to update fooFunc, or vice versa, that would be bad. In addition, I can have many functions, and it would be better to work with both function declarations and typedefs-pointers to functions that are associated with these functions.
Conclusion: AndreyT's answer is the most portable, but if you code gcc, then typeof is a great solution.
source share