The following code:

using GLib;

public class myclass {
    public string test1;
    public int test2;
}

public struct mystruct {
    public string test1;
    public int test2;
}

void main(string[] args)
{
    List<mystruct> ls;
    List<myclass> lc;

    myclass c = new myclass() {test1 = "test", test2=10};
    lc.append(c);

    mystruct m = mystruct() {test1 = "test", test2=10};
    ls.append(m);
}

fails with:

test_list_struct.c: In function '_main':
test_list_struct.c:83: error: incompatible type for argument 2 of
'g_list_append'
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

from the below code, I assume its not valid to use structs in lists?

static void _main (char** args, int args_length1) {
        GList* ls;
        GList* lc;
        myclass* _tmp0;
        myclass* c;
        myclass* _tmp1;
        mystruct _tmp2 = {0};
        mystruct m;
        ls = NULL;
        lc = NULL;
        _tmp0 = NULL;
        c = (_tmp0 = myclass_new (), _tmp0->test1 = "test", _tmp0->test2 = 10, 
_tmp0);
        _tmp1 = NULL;
        lc = g_list_append (lc, (_tmp1 = c, (_tmp1 == NULL ? NULL :
myclass_ref (_tmp1))));
        m = (memset (&_tmp2, 0, sizeof (mystruct)), _tmp2.test1 = "test",
_tmp2.test2 = 10, _tmp2);
        ls = g_list_append (ls, m);
        (ls == NULL ? NULL : (ls = (g_list_free (ls), NULL)));
        (lc == NULL ? NULL : (lc = (_g_list_free_myclass_unref (lc), NULL)));
        (c == NULL ? NULL : (c = (myclass_unref (c), NULL)));
}


-- 
=======================
Cliff Brake
http://bec-systems.com
_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to