After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 587444 - ModuleInit attribute is broken in 0.7.4
ModuleInit attribute is broken in 0.7.4
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: general
0.7.x
Other Linux
: Normal normal
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-06-30 16:56 UTC by Adam Dingle
Modified: 2009-07-10 16:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The patch of Andrea to solve this (456 bytes, patch)
2009-07-04 14:39 UTC, Jaap A. Haitsma
reviewed Details | Review

Description Adam Dingle 2009-06-30 16:56:09 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)
Comment 1 Adam Dingle 2009-07-01 15:52:58 UTC
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.
Comment 2 Jaap A. Haitsma 2009-07-04 14:39:26 UTC
Created attachment 137834 [details] [review]
The patch of Andrea to solve this

Jürg, ok to commit?
Comment 3 Jürg Billeter 2009-07-10 16:20:17 UTC
commit a002d00095ce0c2b6e0d73c2dc176381c6cd0aca
Author: Jürg Billeter <j@bitron.ch>
Date:   Wed Jul 8 11:40:04 2009 +0100

    Fix GTypeModule-based plugins