for example:
int f(int a, int b)
{
return a + b;
}
typeof(f) f2
{
return -f(a, b);
}
Is something like this possible in C?
Edit: The reason I'm asking this is I'm trying to do something like:
#define MAKE_NEGATION_OF(function) \
typeof(function) function##_negated { \
return -function(a, b); \
}
Note that your two examples (used to) differ (before the question was edited).
Given the previous typeof example, you could instead write a macro that generates functions with the same signature, differing only by key tokens:
Given the macro example, there is no need for another function, just negate the function call in a macro wrapper.
If you need a function pointer, then this is an extremely rigid combination of both ideas, which does not scale well at all. If your actual use case is non-trivial, you should probably just write the functions and their signatures by hand.