implementation problem in C

David Janssens dja@info.ucl.ac.be
Thu Jan 30 15:09:00 GMT 2003


Can someone please help me with this simple implementation problem in C:

I have a table in which each entry designates a pointer to some function,
the number of argument it expects and if it returns a value:

typedef struct {
    void *func;
    int argc, ret;
} call_t;

call_t call_table[]={
    {func1, 3, 0},
    {func2, 2, 1},
    {func3, 3, 1},
    ...
}

Now suppose that I have the index to the function I want to call and all the
values of the parameters required, how do I call this function with the
proper parameters passed?
In C, I know how to call a function from a function pointer if the number of
arguments is known statically. But in this case, the number of arguments in
known only dynamically.

thanks,
David



More information about the Gcc-help mailing list