Re: Variables to call...
Posted in 1994
In article <2lfrnm$apo@emory.mathcs.emory.edu> villy@collinscomp.com writes: >Well, I'm not aware of any standard C function that takes a string (char *) >and then executes the function named in that string. It's easy to pass a >function pointer, and have that executed (in fact that is what the >fgl_call routine does when compiled with the 4GL instead of RDS), but >that is a compile time binding, not a run time binding. Sounded like this >guys wants a run time binding to me. I'd love to see the code that let's >you do this is standad C though. C++ can't do it, but Objective-C can >(with a method though, not a standard C function). But in Obj-C, almost >everything is a runtime binding. > >Now, it wouldn't surpise me if somebody, somewhere has a way of shredding >an executable and can figure out from the linking offsets where a >function really ended up, page it in, and execute it. But, that's a >little deeper than my motivations want to take me, and I don't think >Informix has provided it to us. I would also imagine that it may be >platform specific. Agreed, there is no standard way. However for a relatively portable way to do this see the "nlist(3)" man pages. nlist(3) can be used to find the addresses of symbols such as functions and global variables. I have built such a beast for my personal 4GL toolkit and it really works. Scott