On Wed, Jan 18, 2012 at 5:20 PM, Jonathan Ryan <[email protected]>wrote:
> On Wed, Jan 18, 2012 at 11:56 AM, Henrik /KaarPoSoft <[email protected] > > wrote: > >> Dear all, >> >> I am trying to create a new type in vala, >> like "typedef" in C. >> >> http://live.gnome.org/Vala/**Tutorial<http://live.gnome.org/Vala/Tutorial>has >> this example: >> /* defining an alias for a basic type (equivalent to typedef int Integer >> in C)*/ >> [SimpleType] >> public struct Integer : uint {} >> >> However, it does not seem to work... >> >> I have created the following file called i.vala: >> <code> >> [SimpleType] >> public struct Integer : uint { >> } >> public static int main (string[] args) {return 0;} >> </code> >> >> Compiling with valac i.vala gives: >> /home/henrik/v1/i.c: In function ‘integer_get_type’: >> /home/henrik/v1/i.c:22:79: error: ‘integer_dup’ undeclared (first use in >> this function) >> /home/henrik/v1/i.c:22:79: note: each undeclared identifier is reported >> only once for each function it appears in >> /home/henrik/v1/i.c:22:109: error: ‘integer_free’ undeclared (first use >> in this function) >> >> This is running on Linux Mint 12 (like Ubuntu Oneiric) >> Vala 0.14.0 >> gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 >> >> I tried also using latest version of vala from git: >> Vala 0.15.0.72-516e7 >> with the same result. >> >> valac --save-temps shows only this in i.c: >> <snip> >> GType integer_get_type (void) { >> static volatile gsize integer_type_id__volatile = 0; >> if (g_once_init_enter (&integer_type_id__volatile)) { >> GType integer_type_id; >> integer_type_id = g_boxed_type_register_static ("int32_t", >> (GBoxedCopyFunc) integer_dup, (GBoxedFreeFunc) integer_free); >> g_once_init_leave (&integer_type_id__volatile, integer_type_id); >> } >> return integer_type_id__volatile; >> } >> </snip> >> So it is obvious that the C compiler barfs, >> integer_dup and integer_free are never defined. >> >> >> Any help on what I am doing wrong here would be most appreciated! >> >> /Henrik >> ______________________________**_________________ >> vala-list mailing list >> [email protected] >> http://mail.gnome.org/mailman/**listinfo/vala-list<http://mail.gnome.org/mailman/listinfo/vala-list> >> > > Doesn't seem that you're doing anything wrong. Vala isn't generating the > normal dup and free functions for your simple type struct. I'm going to > check bugzilla if there's a bug about it. This should be removed from the > tutorial considering it doesn't work. > It looks like that deriving from any primitive type is broken. You might be able to trick Vala into making it work by defining the functions, but I wouldn't do that. My suggestion is to not do this.
_______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
