GNOME Bugzilla – Bug 587444
ModuleInit attribute is broken in 0.7.4
Last modified: 2009-07-10 16:20:17 UTC
Vala 0.7.4 fails to compile code using the ModuleInit attribute. To see the problem, try to build the following plugin sample code (from http://live.gnome.org/Vala/TypeModules): == plugin-interface.vala == using GLib; public abstract class TestPlugin : Object { public abstract void hello(); } == plugin.vala == using GLib; class MyPlugin : TestPlugin { public override void hello() { stdout.printf("Hello world!\n"); } } [ModuleInit] public Type register_plugin (TypeModule module) { // types are registered automatically return typeof (MyPlugin); } ==== % valac -g -C plugin.vala plugin-interface.vala % gcc -g -shared -fPIC $(pkg-config --cflags --libs glib-2.0) -o libplugin.so plugin.c With Vala 0.7.3 or earlier, this works fine. Vala 0.7.4 yields the following error: plugin.c: In function ‘my_plugin_get_type’: plugin.c:105: error: ‘my_plugin_type_id’ undeclared (first use in this function) plugin.c:105: error: (Each undeclared identifier is reported only once plugin.c:105: error: for each function it appears in.) plugin.c: In function ‘my_plugin_register_type’: plugin.c:111: error: ‘my_plugin_type_id’ undeclared (first use in this function)
Andrea Del Signore posted a fix to vala-list: http://mail.gnome.org/archives/vala-list/2009-June/msg00220.html I tried the fix and it seems to work fine.
Created attachment 137834 [details] [review] The patch of Andrea to solve this Jürg, ok to commit?
commit a002d00095ce0c2b6e0d73c2dc176381c6cd0aca Author: Jürg Billeter <j@bitron.ch> Date: Wed Jul 8 11:40:04 2009 +0100 Fix GTypeModule-based plugins