mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-28 16:30:07 +02:00
Add an example for GModule usage. (#144127, Tommi Komulainen)
Thu Jun 10 21:29:55 2004 Matthias Clasen <maclas@gmx.de> * glib/tmpl/modules.sgml: Add an example for GModule usage. (#144127, Tommi Komulainen)
This commit is contained in:
parent
47d4ea5f83
commit
c441dca3db
@ -1,3 +1,8 @@
|
|||||||
|
Thu Jun 10 21:29:55 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/tmpl/modules.sgml: Add an example for GModule
|
||||||
|
usage. (#144127, Tommi Komulainen)
|
||||||
|
|
||||||
Sun Jun 6 23:20:42 2004 Matthias Clasen <maclas@gmx.de>
|
Sun Jun 6 23:20:42 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
* gobject/tmpl/gtype.sgml: Fix the docs for G_DEFINE_TYPE()
|
* gobject/tmpl/gtype.sgml: Fix the docs for G_DEFINE_TYPE()
|
||||||
|
@ -41,6 +41,48 @@ program, e.g. through calling <literal>g_quark_from_static_string ("my-module-st
|
|||||||
it must ensure that it is never unloaded, by calling g_module_make_resident().
|
it must ensure that it is never unloaded, by calling g_module_make_resident().
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<example>
|
||||||
|
<title>Calling a function defined in a <structname>GModule</structname></title>
|
||||||
|
<programlisting>
|
||||||
|
/* the function signature for 'say_hello' */
|
||||||
|
typedef void (* SayHelloFunc) (const char *message);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
just_say_hello (const char *filename, GError **error)
|
||||||
|
{
|
||||||
|
SayHelloFunc say_hello;
|
||||||
|
GModule *module;
|
||||||
|
|
||||||
|
module = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||||
|
if (!module)
|
||||||
|
{
|
||||||
|
g_set_error (error, FOO_ERROR, FOO_ERROR_BLAH,
|
||||||
|
"%s", g_module_error (<!-- -->));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g_module_symbol (module, "say_hello", (gpointer *)&say_hello))
|
||||||
|
{
|
||||||
|
g_set_error (error, SAY_ERROR, SAY_ERROR_OPEN,
|
||||||
|
"%s: %s", filename, g_module_error (<!-- -->));
|
||||||
|
if (!g_module_close (module))
|
||||||
|
g_warning ("%s: %s", filename, g_module_error (<!-- -->));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* call our function in the module */
|
||||||
|
say_hello ("Hello world!");
|
||||||
|
|
||||||
|
if (!g_module_close (module))
|
||||||
|
g_warning ("%s: %s", filename, g_module_error (<!-- -->));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
</para>
|
||||||
|
|
||||||
<!-- ##### SECTION See_Also ##### -->
|
<!-- ##### SECTION See_Also ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user