Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!mcsun!ukc!edcastle!aiai!aiai.ed.ac.uk!richard From: richard@aiai.ed.ac.uk (Richard Tobin) Newsgroups: comp.lang.c Subject: Re: varargs -> varargs mystery Message-ID: <4606@skye.ed.ac.uk> Date: 3 May 91 14:34:23 GMT References: <3099@cirrusl.UUCP> <1991May2.170148.12655@sparky.IMD.Sterling.COM> Sender: news@aiai.ed.ac.uk Reply-To: richard@aiai.uucp (Richard Tobin) Organization: AIAI, University of Edinburgh, Scotland Lines: 26 In article <1991May2.170148.12655@sparky.IMD.Sterling.COM> rick@sparky.IMD.Sterling.COM (Richard Ohnemus) writes: >In article <3099@cirrusl.UUCP> Rahul Dhesi 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@uk.ac.ed AI Applications Institute, ARPA: R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin