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 683160 - Link error with abstract construct property
Link error with abstract construct property
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.17.x
Other All
: Normal minor
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2012-09-01 15:13 UTC by Thomas Jollans
Modified: 2018-02-23 19:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Thomas Jollans 2012-09-01 15:13:37 UTC
Implementing an abstract construct property in a different file from the one in which it is originally declared is not possible.

Example:

$ cat proptest_iface.vala
public interface HasProperty : Object
{
    public abstract string myprop { get; construct; }
}

$ cat proptest_impl.vala
public abstract class ImplementsProperty  : Object, HasProperty
{
    public string myprop { get; construct; }
}

void main ()
{
}

$ valac-0.18 proptest_iface.vala proptest_impl.vala
/home/tjol/tmp/proptest_impl.vala.c:65:13: warning: ‘has_property_set_myprop’ used but never defined [enabled by default]
/tmp/ccCogCi2.o: In function `_vala_implements_property_set_property':
proptest_impl.vala.c:(.text+0x42a): undefined reference to `has_property_set_myprop'
collect2: ld returned 1 exit status
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)



The reason for this is that the generated set method is static, which makes sense when the property declaration and constructor definition are in the same source file. For abstract properties, this can't be counted on.

static void has_property_set_myprop (HasProperty* self, const gchar* value);
Comment 1 Michael 'Mickey' Lauer 2018-02-23 19:20:16 UTC
Thanks for your bug report. I'm glad to report that this has been fixed in the meantime:

% valac --save-temps proptest_iface.vala proptest_impl.vala

% grep has_property_set_myprop *                                                                                                                    Binary file proptest_iface matches
proptest_iface.c:void has_property_set_myprop (HasProperty* self,
proptest_iface.c:has_property_set_myprop (HasProperty* self,
proptest_impl.c:void has_property_set_myprop (HasProperty* self,
proptest_impl.c:		has_property_set_myprop ((HasProperty*) self, g_value_get_string (value));