[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [Vala] structs and lists
- From: Maciej Piechotka <uzytkownik2 gmail com>
- To: vala-list gnome org
- Subject: Re: [Vala] structs and lists
- Date: Mon, 04 Aug 2008 09:44:23 +0200
Roberto Majadas <roberto majadas openshine com> writes:
> Hi people :
>
> Anybody can help me with this code ? I want to add a struct to a GList.
> But....
>
> valac --pkg glib-2.0 --pkg gtk+-2.0 -o struct struct.vala
>
> struct.c: In function 'xclass_run':
> struct.c:37: error: incompatible type for argument 2 of 'g_list_append'
> error: cc exited with status 256
> Compilation failed: 1 error(s), 0 warning(s)
>
> telemaco
>
> /* -*- Mode: Vala; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
>
> using GLib;
>
>
> struct XStruct
> {
> public int integer;
> public SList items;
> }
>
> public class XClass {
> private List<XStruct> x_list;
>
> construct{
> this.x_list = null;
> }
>
> public void run (){
> var x = XStruct();
> x.integer = 1;
> this.x_list.append(x);
> }
>
> static int main (string[] args) {
> XClass obj = new XClass();
> obj.run();
> return 0;
> }
>
> }
You cannot store structs in list.
1. Use class
2. Use pointers or other type of references
Regards
--
I've probably left my head... somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]