public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* implementation problem in C
@ 2003-01-30 15:09 David Janssens
  2003-01-30 15:23 ` Momchil Velikov
  0 siblings, 1 reply; 2+ messages in thread
From: David Janssens @ 2003-01-30 15:09 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: implementation problem in C
  2003-01-30 15:09 implementation problem in C David Janssens
@ 2003-01-30 15:23 ` Momchil Velikov
  0 siblings, 0 replies; 2+ messages in thread
From: Momchil Velikov @ 2003-01-30 15:23 UTC (permalink / raw)
  To: David Janssens; +Cc: gcc-help

>>>>> "David" == David Janssens <dja@info.ucl.ac.be> writes:

    David> Can someone please help me with this simple implementation problem in C:
    David> I have a table in which each entry designates a pointer to some function,
    David> the number of argument it expects and if it returns a value:


In GCC, try ``__builtin_apply''.  Alternatively, you may want to
recode the functions to take variable number of arguments.

~velco

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-30 15:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-30 15:09 implementation problem in C David Janssens
2003-01-30 15:23 ` Momchil Velikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).