Invalid initializer in C

February 19, 2009 at 21:42:06
Specs: Windows XP
Hi friends...i am facing a problem in initializing a const structure.

i have defined the following two structures and want to create constant instances of these two.

uint8 buf[] = {0x0,0x1};
uint8 buf1[] = {0x0,0x1,0x3};
uint8 buf2[] = {0x0,0x2,0x4,0x5};
uint8 buf3[] = {0x0,0x6};

struct PduInfoType
uint16 len;
uint8* Data;


typedef struct
uint8 CanTpTxNpduId;
const struct PduInfoType *CanTpTxNpduRef;

this is how i am initilaizing the constant structures...

const struct PduInfoType PduInfoPtr[4] = {{0x2,&buf[0]},{0x3,&buf1[0]},{0x4,&buf2[0]},{0x2,&buf3[0]}};

const CanTpTxNpdu_Type CanTpTxNpduptr1[4] =

Compiler is showing an error i.e. "Invalid initializer" for the initialization of structure CanTpTxNpduptr1. can any one please help me out in solving this???...thanks in advance..:))))

See More: Invalid initializer in C

Report •

February 20, 2009 at 08:29:26
It works fine when I try it. You do, of course, need to correct your syntax error by balancing the braces.

Report •
Related Solutions

Ask Question