on the fringe of C syntax/semantics
James L. Peterson/1000000
peterson at lyle.UUCP
Tue Oct 10 08:16:21 AEST 1989
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 at ibmaus.uucp
Austin, Texas 78758-2603 !&@: ibmaus!peterson at CS.UTEXAS.EDU
(512) 823-5169 vnet: JPETER at AUSVM6
More information about the Comp.lang.c
mailing list