I have thousands of function wrappers which inside actually perform a similar logic like:
// a, b, ... are variable length parameters of different type
void API_Wrapper(hHandle, a, b, ..)
{
if (hHandle)
return remote_API(hHandle, a, b, ..);
else
return API(a, b, ..);
}
I want to use a macro to reuse the if-else logic so I can simply implement the function like this:
void API_Wrapper(hHandle, a, b, ..)
{
API_CALL(api_name, hHandle, a, b, ..); // API_CALL is a macro
}
I didn’t come up with a good way. (Note: I could solve it via … and __va_args__ but this extension is not supported by the compiler we currently use)
Anyone ever met the same problem and any idea?
Another trick, without variadic macro’s:
Which becomes: