Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!ut-emx!ibmchs!auschs!lyle!peterson From: peterson@lyle.UUCP (James L. Peterson/1000000) Newsgroups: comp.lang.c Subject: Re: on the fringe of C syntax/semantics Summary: Another varargs problem Message-ID: <2792@lyle.UUCP> Date: 9 Oct 89 22:16:21 GMT References: <80100001@bonzo> <19971@mimsy.UUCP> Organization: IBM AWD, Austin, TX Lines: 38 We have run into a problem that looks like it should be solvable with var_args, but after an attempt feel that something is missing. We have a number of routines which call other routines. We want to interpose a general routine between each caller and called routine. The parameter lists always have the same first element, followed by other parameters as appropriate for the called routine. We want the one general routine to work with the first parameter and then pass the entire parameter list that it got on to the called routine. The interposed general routine does not know how many or what types of parameters it will get, so varargs seems appropriate. We can get the first parameter out of the list by using va_arg. Based on this, and other info, we can compute a pointer to the routine that was being called (realfunc). We then want to call the realfunc with the same parameter list that we got (whatever it was). Something like: general(va_alist) va_dcl { va_start(argp); first = va_arg(argp,type); ... do stuff with first ... (*realfunc)(first, rest); } How do we refer to the "rest of the argument list". Or since we just want to send the same thing out that we got in, is there a way to make the (*realfunc) call with the incoming va_alist ? -- James L. Peterson IBM Advanced Workstations Div. !'s: cs.utexas.edu!ibmaus!peterson 11400 Burnet Road, D75/996 @'s: @CS.UTEXAS.EDU:peterson@ibmaus.uucp Austin, Texas 78758-2603 !&@: ibmaus!peterson@CS.UTEXAS.EDU (512) 823-5169 vnet: JPETER at AUSVM6