PDA

View Full Version : multidimensional array: alternative?


Sinner
02/08/2012, 12:36 PM
I'm making an include for something, and I need to address a multidimensional array within an enum. The following example will not work:



// This, ofcourse, will not give any errors
#define ARRAY_SIZE 10
#define ENUM_SIZE 10

enum edata {
E_DATA[ARRAY_SIZE]
}
new Enum[ENUM_SIZE][edata];

// This will not work, assuming "idx" is a valid index (Line 45)

Enum[idx][E_DATA[idx]] = someValue;

// This also gives some errors
Enum[idx][E_DATA][idx] = someValue;



Are there any alternatives for this? i'd like to keep the enum as this simplifies my problem. The errors are as followed:


C:~PATH~\~INCLUDE~.inc(45) : error 028: invalid subscript (not an array or too many subscripts): "E_DATA"
C:~PATH~\~INCLUDE~.inc(45) : warning 215: expression has no effect
C:~PATH~\~INCLUDE~.inc(45) : error 001: expected token: ";", but found "]"
C:~PATH~\~INCLUDE~.inc(45) : error 029: invalid expression, assumed zero
C:~PATH~\~INCLUDE~.inc(45) : fatal error 107: too many error messages on one line

Vince
02/08/2012, 12:40 PM
I think it's:

Enum[idx][E_DATA][idx] = someValue;

Otherwise make a normal three dimensional array.

Sinner
02/08/2012, 12:41 PM
I think it's:

Enum[idx][E_DATA][idx] = someValue;

Otherwise make a normal three dimensional array.

My bad I didn't put it in the post. The errors for that case are as followed:


C:~PATH~/~INCLUDE~.inc(45) : warning 213: tag mismatch
C:~PATH~/~INCLUDE~.inc(45) : error 032: array index out of bounds (variable "Enum")
C:~PATH~/~INCLUDE~.inc(52) : error 008: must be a constant expression; assumed zero
C:~PATH~/~INCLUDE~.inc(52) : error 009: invalid array size (negative, zero or out of bounds)
C:~PATH~/~INCLUDE~.inc(52) : error 036: empty statement
C:~PATH~/~INCLUDE~.inc(52) : fatal error 107: too many error messages on one line