Re: [gtk-list] GModule (continued)

On Wed, 17 Mar 1999, D. Emilio Grimaldo Tunon wrote:

> Well, here is question #2 for GModule, hopefully somebody can
> clear this thing out.
> In gmodule.c there is a check for a symbols g_module_check_init
> and g_module_unload, but I see that such thing is available only
> in libgplugin_b.c and not in libgplugin_a.c. So, do I *need*
> to have such symbol/function in *all* the modules I write?
> or what's the catch about one having it and not the other?

G_MODULE_EXPORT const gchar*
g_module_check_init (GModule *module)
  g_print ("GPluginB: check-init\n");

  return NULL;

g_module_check_init is a special function, featured by the gmodule
code, if it is present, it will be called upon g_module_open() and if
it returns non-NULL, module loading is considered unsuccessfull and the
return value is issued in an error message.

g_module_unload (GModule *module)
  g_print ("GPluginB: unloaded\n");

g_module_unload is simply called before the moduele is removed from memory,
if it is present.
neither of these functions is required to get a gmodule to work though.

but for instance g_module_check_init() can become pretty convenint to check
for binary compatibility:

G_MODULE_EXPORT const gchar*
g_module_check_init (GModule *module)
  /* gtk_check_version() returns an appropriate error string if
   * the gtk+ version is too old or too new for the requirements
   * of the compile time gtk+ API.
   * this asures that we will get unloaded if we're not binary
   * compatible with the applications gtk+ version.
  return gtk_check_version (GTK_MAJOR_VERSION,
                            GTK_MICRO_VERSION - GTK_INTERFACE_AGE);

> 		TIA,
> 				Emilio


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]