stdarg question

139a80000-HallM(DR3132)37x10 marcus@bighorn.dr.lucent.com
Wed Jun 30 22:10:00 GMT 1999


> I have a function using the stdarg facility such as:
> 
> myfunc(arg1, arg2, ...)
> 
> and in its body I want to pass the stdarg (vararg) part of the stack such as:
> 
> myfunc(arg1, arg2, ...)
> {
> 
> /* do stuff */
> 
> anotherfunction(argA, ...);
> 
> /* do more stuff */
> 
> return;
> }
> 
> But because there is no parameter name for the vararg argument part (i.e.:  
> ...) I don't see how to pass that to anotherfunction()
> 
> Can passing the vararg part be done? How?

What you have to do is to pass the argument vector to the second function.
You must have another version of "anotherfunction()" that takes a va_list
as an argument instead of a variable number of arguments (like vprintf()).

Your function would be similar to this:

extern void vanotherfunction(va_list);

void
myfunc(arg1, arg2, ...)
{
va_list arglist;

va_start(arglist, arg2);
vanotherfunction(arglist);
va_end(arglist);

}


Within vanotherfunction(), you manilulate arglist as if you had done a
va_start() there, but the va_start is actually done in myfunc().

marcus hall

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list