Re: [Vala] Can fixed-size arrays be initialized?
- From: Graham Whelan <gawhelan gmail com>
- To: Marco Trevisan (Treviño) <mail 3v1n0 net>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Can fixed-size arrays be initialized?
- Date: Thu, 3 Mar 2011 17:34:03 +0000
On 3 March 2011 15:57, Marco Trevisan (Treviño) <mail 3v1n0 net> wrote:
Il giorno gio, 03/03/2011 alle 16.54 +0100, Marco Trevisan (Treviño) ha
scritto:
Il giorno mer, 02/03/2011 alle 20.33 +0000, Graham Whelan ha scritto:
int main (string[] args) {
int a[5] = {1, 2, 3, 4, 5};
return 0;
}
You should use:
int[] a = {1, 2, 3, 4, 5};
Sorry I forgot const... The array should be set as constant:
const int[] a = {1, 2, 3, 4, 5};
So the generated C code will be:
static const gint a[5] = {1, 2, 3, 4, 5};
I understand that Vala provides that syntax for declaring dynamic
arrays but I thought it also supported the normal C syntax for
fixed-size arrays. However the Vala compiler doesn't seem to handle
non-const fixed-size array initialization.
dynamic array syntax:
const int[] a = {1, 2, 3}; /* compiles*/
int[] a = {1, 2, 3}; /* compiles */
fixed-size array syntax:
const a[] = {1, 2, 3}; /* compiles */
int a[] = {1, 2, 3}; /* does not compile */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]