This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: stdarg question



> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]