Follows from C variadic functions.
Passing variadic arguments from one variadic function to the other is not possible. Instead we have to implement a function variant taking va_list
instead. These variants usually start with v
in standard library. See vprintf
and variations.
This is how we can implement v
variation of functions along with keeping the variadic function too.
void foo(const char* format, ...) {
va_list args;
va_start(args);
// Do something before & after calling vbar
vbar(format, args);
va_end(args);
}
void bar(const char* format, ...) {
va_list args;
va_start(args);
vbar(format, args);
va_end(args);
}
void vbar(const char* format, va_list list) {
// va_start and va_end are taken care of outside
// Just do stuff with args here
}