Given I have the function:
void A::IAmCool(int x, ...)
{
va_list args;
va_start (args, x);
va_end (args);
}
How do I pass var-args from one function to another? I’m looking for something like this:
void A::extractedFunction() /* this doesn't work */
{
va_list args;
va_start (args, ?????);
va_end (args);
}
void A::IAmCool(int x, ...)
{
extractedFunction();
}
Is this even possible? I have tried making the function inline but that doesn’t work.
The usual pattern is to implement your main workhorse function taking a valist, and the variadic function only as “decoration”. Then you can use the main function directly from third-party call sites. Example: