www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Passing variable arguments through a function pointer Q.

I'm looking to create a function which can take a pointer to a function with any
number of arguments, and any number of additional arguments, and call that
function with the supplied arguments, I'm not aware of how to do this.

Pseudo-Code idea:
void Foo(void * vdFunction(), ...)
{
vdFunction(*arguments*);
}

I know one method would be to use stdargs.h, get the number of arguments passed,
and switch depending on the number of arguments, passing to the function each
argument iterated out, but that seems to be rather sloppy, and I can only have
as many arguments as I supply switch statements. Is there a better way to do
this?

Additionally, is there a way, in my code, to get a pointer to each function in
my code?

Thanks in advance.
Sep 11 2003