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




Try this code:
enum stats_parameters {
#ifdef EMBEDED
MAX_EVENTS=2
#else
MAX_EVENTS=20
#endif
}
 
 
int statistics[stats_parameters.MAX_EVENTS];
int foo[stats_parameters.MAX_EVENTS];
 
 
int bar[stats_parameters.MAX_EVENTS];Vala enums must be used with the enum name.

Yours,
Tal

Date: Sun, 12 Aug 2012 18:10:00 +0600
From: kamanashisroy gmail com
To: vala-list gnome org
Subject: [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

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


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