[Vala] Declare array of enumerated(enum) value size



Hi,

  I was rewriting some of my (C)code in vala. I used to do the following in
my C code,

<pre>

enum {
#ifdef EMBEDED
MAX_EVENTS=2
#else
MAX_EVENTS=20
#endif
};


int statistics[MAX_EVENTS];
int foo[MAX_EVENTS];


int bar[MAX_EVENTS];

</pre>

   Unfortunately I am not allowed to use enum identifier inside array
declaration. Is there any problem in this idea ? I mean this feature is
very useful.
I wanted to write code something like this,

<pre>


enum stats_parameters {
#ifdef EMBEDED
MAX_EVENTS=2
#else
MAX_EVENTS=20
#endif
}


int statistics[MAX_EVENTS];
int foo[MAX_EVENTS];


int bar[MAX_EVENTS];

</pre>


   And if this feature is not feasible then do you know any work around ?

   And if you think you like this idea, then can you please suggest me the
place to edit ? Because I have little experience working on your compiler
code..


-- 
-- Thanks

Kamanashis Roy


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