I was wondering if it is possible to dynamically call a function at run-time without the program knowing what the function is or how many arguments or what type thae args are.
(E.g.
func (args);
)
I was wondering if it is possible to dynamically call a function at run-time without the program knowing what the function is or how many arguments or what type thae args are.
(E.g.
func (args);
)
Off the top of my head, you can dynamically call a function at run-time by using function pointers. However, I don't think you do that without knowing the "signature" of the function -- i.e. how many args and what they are.
You might be able to do something va_arg lists, in your various fucntions, but I've never tried it.
If it's a function you're writing, you can write it to accept a variable number of arguments and use function pointers as fgw_three said, but I don't think it's possible if it's some arbitrary function - it has to be able to accept variable arguments.
I second what the other responders have said.
It is possible to create a call at runtime if you have an intimate knowlege of the function linkage and are willing to use assembly language to do it. It is unlikely that you can do it with pure C code, and whatever it is will not be portable to other environments. Most source level debuggers have this capability, but they use platform specific code (most often in assembly code) to implement it.
Insert obnoxious but pithy remark here