Greg
testplugin.c (to be compiled into a dynamically loadable library)
--------------------------
#include <glib.h>
#include <gmodule.h>
G_MODULE_EXPORT int test_func(gboolean bar) {
return bar ? 1 : 2;
}
test.c (an executable that loads the library at runtime)
------------------------
#include <glib.h>
#include <gmodule.h>
#define PLUGIN_FILE "./libtestplugin.so"
typedef int (* TestFunc) (gboolean);
int main() {
GModule *mod;
TestFunc module_func;
// open the module
g_assert(g_module_supported());
g_assert((mod = g_module_open(PLUGIN_FILE, G_MODULE_BIND_LAZY)) != NULL);
// get a pointer a function
g_assert(g_module_symbol(mod, "test_func", (gpointer)module_func));
// test a module function
g_print("%i\n", module_func(TRUE));
g_print("%i\n", module_func(FALSE));
return 0;
}
_______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list