C
Calum
I need to call a function in a shared library, but the type of the
function is not known until run-time.
enum Type { Void=0, Char, Uchar, Short, Ushort, Int, Uint, Float,
Double, String };
void call_unknown_function(
void *function,
enum Type retType, void *retAddress,
...);
The variable arguments are pairs of (Type,pointer), terminated by 0. So
to call double sqrt(double), it would be
double result, n=2.0;
call_unknown_function(sqrt, Double, &result, Double, &n, 0);
So how could I implement such a function? I would prefer not to resort
to assembly language.
Cheers,
Calum
function is not known until run-time.
enum Type { Void=0, Char, Uchar, Short, Ushort, Int, Uint, Float,
Double, String };
void call_unknown_function(
void *function,
enum Type retType, void *retAddress,
...);
The variable arguments are pairs of (Type,pointer), terminated by 0. So
to call double sqrt(double), it would be
double result, n=2.0;
call_unknown_function(sqrt, Double, &result, Double, &n, 0);
So how could I implement such a function? I would prefer not to resort
to assembly language.
Cheers,
Calum