[Vala] Initialization Error!!!



Hello

The following code do not work because the value in 'x' and 'y' in 'd' are not 24 and 3.
The structure is not initialized in an appropriate manner.

using GLib;

public class Sample : Object
{
    struct Data
    {
        public int x;
        public int y;
    }
   
    public static void main (string[] args)
    {
        int i = 24;
        int j = 3;
        Data d = {i, j};

        stdout.printf ("x = %d, y = %d\n", d.x, d.y);
    }
}


In the C code, I see that in the structure is initialized before the variables:

    gint i;
    gint j;
    SampleData d = {i, j};
    i = 24;
    j = 3;


Can anyone fix this? Because when i work with pointer there is a Segmentation Fault. Thanks

Matias


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]