GNOME Bugzilla – Bug 675107
Strange behaviour with libgee-0.8
Last modified: 2018-05-22 14:24:21 UTC
This bit of code: class MixedArray: Gee.HashMap<string, GLib.Value> {} Compiles fine in vala, but produces compiler errors from GCC: $ valac --library=test valatest.vala --pkg gee-0.8 d:/dev/valatest.vala.c: In function 'mixed_array_construct': d:/dev/valatest.vala.c:45: error: expected expression before ',' token d:/dev/valatest.vala.c:45: warning: passing argument 7 of 'gee_hash_map_construct' from incompatible pointer type Compilation failed: 1 error(s), 0 warning(s) error: cc exited with status 1 I get similar errors from Microsoft's CL compiler (same line of code, but in my actual project this time): d:/dev/gstflvhttpsink/amf.vala(54) : error C2059: syntax error : ',' amf.c(409) : error C2143: syntax error : missing '{' before '*' amf.c(409) : error C2371: 'amf_mixed_array_new' : redefinition; different basic types d:/dev/gstflvhttpsink/amf.vala(250) : error C2172: 'gee_abstract_map_set' : actual parameter is not a pointer : parameter 3 I've tried all combinations of explicit base class constructor instantiation, including passing explicit arguments. Same errors occur. I thought someone might find this interesting.
You must box GLib.Value: class MixedArray: Gee.HashMap<string, GLib.Value?> {}
Yeah, sorry about that. I typed it from memory. I forgot to mention that the compiler accepts it without throwing an error. And in my project, even when boxed, doing something like this: [Compact] class Message: Object { struct Header { int dummy; // ... } class HeaderCollection: Gee.HashMap<string, GLib.Value?> {} HeaderCollection headers; } Causes GCC/CL to throw errors at the generated code.
Thanks for your bug report. With the current version I get the following error: /tmp/bug675107.vala.c:48:158: error: expected expression ...(object_type, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_VALUE, (GBoxedCopyFunc) , (GDestroyNotify) g_value_uns...
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/296.