Note that variable argument functions must have a way to determine the types of the arguments in the ellipsis (va_list
). The printf()
and scanf()
families of functions have the format string to specify the types; the open()
system call has an optional third argument but it is always an int
; and the execl()
function takes a list of arguments all of the same type, char *
, terminated by a NULL pointer).
If you have a function:
void foo_tail(va_list args);
You can write your function foo()
as:
int foo(char *a, ...)
{
va_list args;
va_start(args, a);
int arg2 = va_arg(args, int);
foo_tail(args);
va_end(args);
return arg2;
}
This achieves what the question asks for:
remove parameter '2' from the
va_list
got and make anotherva_list
with the rest.
Whether foo_tail()
can work out what to do with the va_list
it is given is a separate discussion; it is not clear how it would distinguish between the two calls shown in the question, but to handle both, that information would have to be made available somehow. A variable list of mixed types as shown is very problematic.