Re: [Vala] (no subject)



The subject of this should read "Null type error when using option outside
of construction" but for whatever reason (maybe pebcak) didn't stick to the
original post.

On Wed, Jan 18, 2012 at 10:28 AM, Geoff Johnson <geoff jay gmail com> wrote:

I'm using the following code to read command line arguments for two integer
values

------------------

// inside of a class

static int opt_x_part = 0;
static int opt_y_part = 0;

...

public static const OptionEntry[] options = {
   { "xpart", 0, 0, OptionArg.INT, ref opt_x_part,
     "Number of partitions in the x direction", null },
   { "ypart", 0, 0, OptionArg.INT, ref opt_y_part,
     "Number of partitions in the y direction", null },
   { null }
};

...

public int x_part { get; set; default=0; }
public int y_part { get; set; default=0; }
public int n_part { get; set; default=0; }

...

// in the constructor

if (opt_x_part != 0) {
   x_part = opt_x_part;
}
if (opt_y_part != 0) {
   y_part = opt_y_part;
}

n_part = x_part * y_part;

------------------

Later on in the code I want to use n_part but whenever I do I get the
following error during compile:

julia.vala:166.21-166.30: error: Relational operation not supported for
types `int' and `null'
       for (i = 0; i < n_part; i++) {

I assume that it thinks that there's a chance that n_part could be null
because of the ref to opt_x_part/opt_y_part made in the options, but I'm a
little confused as to why they are usable during construction but not
afterwards. What is the way to deal with options correctly to avoid this
error?

Thanks,
Geoff

_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




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