Is there a way to implement this?
void func2(...) {
/*
* Handle „...” parameters
*/
}
void func1(int n, ...) {
func2(...);
}
Is there a way to implement this?
void func2(...) {
/*
* Handle „...” parameters
*/
}
void func1(int n, ...) {
func2(...);
}
No, you can't. Variadic arguments cannot be forwarded. Your choices are:
have your "inner" function take a(n initialized) va_list
argument instead of ...
and pass that list from the caller;
if the arguments are of the same (or convertible) types, you can make it accept an array, then parse the variadic arguments yourself and pass the array and its length to the called function.
This is impossible according to Wikipedia. http://en.wikipedia.org/wiki/Stdarg.h
Variadic functions are functions which may take a variable number of arguments and are declared with an ellipsis in place of the last parameter. An example of such a function is printf. Variadic functions must have at least one named parameter, so, for instance,
char *wrong(...);
is not allowed in C. (In C++, such a declaration is permitted, but not very useful.) In C, a comma must precede the ellipsis; in C++, it is optional.
So your void func2(...)
is illegal.