varargs -> varargs mystery

Richard Tobin richard at aiai.ed.ac.uk
Sat May 4 00:34:23 AEST 1991


In article <1991May2.170148.12655 at sparky.IMD.Sterling.COM> rick at sparky.IMD.Sterling.COM (Richard Ohnemus) writes:
>In article <3099 at cirrusl.UUCP> Rahul Dhesi <dhesi at cirrus.COM> writes:
>>Suppose A is a varargs function, and it uses the first argument
>>supplied, and passes on the rest to B, which is also a varargs
>>function.  What is the right way to do it?

It can't be done.  What Rahul wants is the equivalent of Lisp's
"apply", and C doesn't have one.

>Just pass the variable argument list pointer instead of the address of 
>the pointer.

Note that he wanted to pass the arguments on to another varargs
function, not one that took a single va_list argument.

Imagine a function debug() which takes a "debugging level" and and
some arguments that will be passed on to fprintf() if the level is
high enough.  For this particular case C provides the functions
vfprintf() etc.  If there were a (portable) way to do what Rahul
wanted, those functions would be unnecessary.

-- Richard

Richard Tobin,                       JANET: R.Tobin at uk.ac.ed             
AI Applications Institute,           ARPA:  R.Tobin%uk.ac.ed at nsfnet-relay.ac.uk
Edinburgh University.                UUCP:  ...!ukc!ed.ac.uk!R.Tobin



More information about the Comp.lang.c mailing list