[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: calling functions from loadable modules
- From: David Odin <David Odin bigfoot com>
- To: gtk-app-devel-list redhat com
- Subject: Re: calling functions from loadable modules
- Date: Mon, 18 Oct 1999 17:24:33 +0200
On Mon, Oct 18, 1999 at 02:59:21PM +0200, Willem Robert van Hage wrote:
> Dear members of this excellent list :)
>
> Does anybody know how to call functions
> from modules loaded with g_module_open etc
> when you only know the name of the function as a string?
>
> I want to use this in my game, because my data files
> that describe my monsters are in plain ASCII
> and I want to separate the functions that describe the
> monsters' behaviour from the game engine, so that you
> can make monsters without editing and recompiling the game itsself.
> but that means I got to be able to derive the function pointer
> from a string...
>
the following function may be what you're looking for :
gboolean g_module_symbol(GModule *module,
const gchar *symbole_name,
gpointer *symbol);
You can use it like this :
[ ... ]
GModule *module;
void (*MyPrintFunc)(gchar *);
module = g_module_open("mymodule.so", 0);
g_module_symbol(module, "PrintIt", (gpointer *)(&MyPrintFunc));
MyPrintFunc("Hello");
[ ... ]
Hope this helps.
DindinX
--
David.Odin@bigfoot.com
Any stone in your boot always migrates against the pressure gradient to
exactly the point of most pressure.
-- Milt Barber
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]