[JDEV] Scripting/Modules/Rant
Jon A. Cruz
joncruz at geocities.com
Thu Aug 12 23:59:03 CDT 1999
arh14 at cornell.edu wrote:
> On Wed, 11 Aug 1999, Aaron Brady (insomnike) wrote:
>
> > And example of how procedures are run from a .so file:
> >
> > void main(void) {
> > void *phoe = dlopen ("mod_filetrans.so", RTLD_LAZY);
> > int (*funk)(int) = dlsym(phoe, "handle_prefs");
> > printf ("[%d]\n", (*funk)(1));
> > dlclose(phoe);
> > }
>
> Somewhat like the Win32 Way. The same general thing happens: you load
> the DLL (~dlopen), you find a pointer to the function you want (~dlsym),
> then you use the pointer as a function pointer and call it (~*funk).
Well, actually that's the much lesser used Win32 way.
The more common way is just to statically link with a DLL's .LIB file, then
the OS takes care of fixup at run-time. For the programmer it looks just
like calling normal functions in a statically linked lib. Looks like this:
void main(void) {
printf ("[%d]\n", handle_prefs(1));
}
But then again, the point is that the dynamic load concept is not
completely foreign to Win32 programmers.
--
"My new computer's got the clocks, it rocks
But it was obsolete before I opened the box" - W.A.Y.
More information about the JDev
mailing list