O
Olaf Dietrich
I may just be temporarily (hopefully ...) stupid, but how can
I pass a function pointer between functions using an array of
(signed/unsigned) chars (in a standard-conforming way)?
E.g.:
I have a function: int (*func)(double, int).
Now I'd like to store the "address" of this function
in an array (of sufficient size) of chars, e.g. in
char func_addr[100]. (How can I do this?)
And finally I would like to use this address in another
function pointer:
new_func = (int (*)(double, int)) func_addr.
This doesn't work - gcc complains: "ISO C forbids conversion
of object pointer to function pointer type".
Is there a way to store the data that constitutes the function
pointer in an array of chars (that need not have the size of
an object pointer)? And then to re-interpret this sequence of
bytes again as a function pointer?
Thanks for any suggestions
Olaf
I pass a function pointer between functions using an array of
(signed/unsigned) chars (in a standard-conforming way)?
E.g.:
I have a function: int (*func)(double, int).
Now I'd like to store the "address" of this function
in an array (of sufficient size) of chars, e.g. in
char func_addr[100]. (How can I do this?)
And finally I would like to use this address in another
function pointer:
new_func = (int (*)(double, int)) func_addr.
This doesn't work - gcc complains: "ISO C forbids conversion
of object pointer to function pointer type".
Is there a way to store the data that constitutes the function
pointer in an array of chars (that need not have the size of
an object pointer)? And then to re-interpret this sequence of
bytes again as a function pointer?
Thanks for any suggestions
Olaf