odd problem with static initializers

R

Ric Has

I have the following code which won't compile:

typedef myType1 {
unsigned short v1,
unsigned char v2,
unsigned char v3
}

enum signals {
SIG_A,
SIG_B,
SIG_C
};

static const myType myEvents[] = {
{SIG_A, 0, 0},
{SIG_B, 0, 0},
{SIG_C, 0, 0}
};

The compiler error is
error: a brace-enclosed initializer is not allowed here before '{' token

This compiled fine with an old version of gcc, I think 2.96. This error
came from a more recent
vintage, 3.3.1.

Can anyone tell me why this isn't compiling? Thanks.

Ric
 
I

Ioannis Vranos

Ric said:
I have the following code which won't compile:

typedef myType1 {
unsigned short v1,
unsigned char v2,
unsigned char v3
}



What's this? Perhaps you meant

struct myType1 {
unsigned short v1;
unsigned char v2;
unsigned char v3;
};


or even this unusual:


typedef struct myType1 {
unsigned short v1;
unsigned char v2;
unsigned char v3;
};




enum signals {
SIG_A,
SIG_B,
SIG_C
};

static const myType myEvents[] = {


static const myType1 myEvents[] = {
 
R

Ric Has

Yes, I meant struct, not typedef. I have the same error when I do typedef
struct myType1...

Ric said:
I have the following code which won't compile:
typedef myType1 {
unsigned short v1,
unsigned char v2,
unsigned char v3
}



What's this? Perhaps you meant

struct myType1 {
unsigned short v1;
unsigned char v2;
unsigned char v3;
};


or even this unusual:


typedef struct myType1 {
unsigned short v1;
unsigned char v2;
unsigned char v3;
};




enum signals {
SIG_A,
SIG_B,
SIG_C
};
static const myType myEvents[] = {


static const myType1 myEvents[] = {


{SIG_A, 0, 0},
{SIG_B, 0, 0},
{SIG_C, 0, 0}
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top