passing variable numbers of arguments

Steve Summit scs at adam.pika.mit.edu
Tue Jan 10 14:09:06 AEST 1989


In article <8699 at alice.UUCP> ark at alice.UUCP (Andrew Koenig) writes:
>There is no way to pass your entire argument list to another function.

Well, no socially acceptable way, maybe, but in the words of
Romeo Void, "Never say 'Never'."  I've got a routine called
"callg," named after the VAX instruction of the same name, which
lets you call an arbitrary function with an arbitrary number of
arguments.  It's sort of an inverse varargs.  Among other things,
I have used it to solve exactly the problem being discussed here,
namely to call a varargs function from a varargs function,
explicitly passing all of the first varargs function's arguments,
rather than indirectly through a va_list.

callg is actually implemented such that its invocation is (well,
could be, I haven't tried it everywhere) portable, although the
underlying implementation is obviously highly machine dependent.
(It's one of a handful of functions I know of that can't possibly
be written in C.)

                                            Steve Summit
                                            scs at adam.pika.mit.edu



More information about the Comp.lang.c mailing list