ispaleny
asked on
Strange enumeration in GNUC syntax
Hi,
I tried to compile GNUC code in Visual Studio C++ 6.0. I am able to compile all code, except something like this:
typedef enum expr_type {
X_TYPE,
A_TYPE,
B_TYPE,
MAX_INDEX
} expr_type_enum;
static int x_type_value[MAX_INDEX] =
{
[ A_TYPE ] = 1,
[ B_TYPE ] = 2,
[ B2_TYPE ] = 2,
};
static enum expr_type expr_x[MAX_INDEX] =
{
[ 0 ] = 0,
[ 1 ] = A_TYPE,
[ 2 ] = B_TYPE,
[ 3 ] = 0,
};
How are used those strange "[ Item ]" enumerations? VS Compiler doesn't like it. The last comma is unusual too.
Any suggestions?
I tried to compile GNUC code in Visual Studio C++ 6.0. I am able to compile all code, except something like this:
typedef enum expr_type {
X_TYPE,
A_TYPE,
B_TYPE,
MAX_INDEX
} expr_type_enum;
static int x_type_value[MAX_INDEX] =
{
[ A_TYPE ] = 1,
[ B_TYPE ] = 2,
[ B2_TYPE ] = 2,
};
static enum expr_type expr_x[MAX_INDEX] =
{
[ 0 ] = 0,
[ 1 ] = A_TYPE,
[ 2 ] = B_TYPE,
[ 3 ] = 0,
};
How are used those strange "[ Item ]" enumerations? VS Compiler doesn't like it. The last comma is unusual too.
Any suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ozo,
I verified the functionality and replaced it by a very long list of mixed zeroes and values.
Thank you.
I verified the functionality and replaced it by a very long list of mixed zeroes and values.
Thank you.
ASKER
static enum expr_type expr_x[MAX_INDEX] ={0,A_TYPE,B_TYPE,0}
But what should I do with x_type_value in Visual Studio? Is the hardcoded order of values necessary?