Hello,
I have this kind of pattern in my code:
namespace Plop {
int my_int = -1;
static void check_my_int_is_initialized() {
if (my_int < 0)
my_int = 42;
}
public static int main(string[] args) {
check_my_int_is_initialized();
stdout.printf(@"my_int is $my_int\n");
return 0;
}
}
and when I try to compile it, I get the following error:
$ valac main.vala
main.vala:2.2-2.11: error: Non-constant field initializers not supported in this
context
int my_int = -1;
^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
I don't understand the issue, because I would've though that -1 is a constant
value. Isn't it the case for vala ? Or is it an inadequate error message for
another error which I am missing ?
Thank you in advance !
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list