(Jens Thoms Toerring) wrote:
# etienne <> wrote:
# > I am looking for help for a cast problem:
# > I want to run functions in thread, using the pthread_create function.
# > The function to run is the first argument of pthread_create and is
# > expected to be of type void* (*func)(void*)
# > My problem is that I want to get the name of the function to run in
# > a .txt file that I parse at runtime.
# > I read the file and I get the name in a char* variable.
# > Now I want that this char* variable is the name of the function to
# > run. How do I do that?
# > I want to do something like:
# > char *func_to_run = scanf(the, good, args);
# > pthread_create (thread, attr, (magic cast)func_to_run, arg);
#
# Unfortunately, there's no "magic cast" that can convert a
# string into a pointer to a function of that name, simply
# because information about function and variable names is
There is no magic cast in ANSI C, but there may be system
specific ways to get this. For example, you may be able to
get a load map from the loader and postprocess this into
a function name map; but this would specific to your loader
and development system.
--
SM Ryan
http://www.rawbw.com/~wyrmwif/
If you plan to shoplift, let us know.
Thanks