Computing.Net > Forums > Programming > Invalid initializer in C

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Invalid initializer in C

Reply to Message Icon

Name: lok
Date: February 19, 2009 at 21:42:06 Pacific
OS: Windows XP
Subcategory: C/C++
Comment:

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;
}CanTpTxNpdu_Type;

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] =
{{0x0,&PduInfoPtr[0]},{0x1,&PduInfoPtr[1]},{0x2,&PduInfoPtr[2]},
{0x3,&PduInfoPtr[3]};

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..:))))



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: February 20, 2009 at 08:29:26 Pacific
Reply:

It works fine when I try it. You do, of course, need to correct your syntax error by balancing the braces.


0
Reply to Message Icon

Related Posts

See More


Structure Chart Help! Visual Basic



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Invalid initializer in C

Simple design questions in C++ www.computing.net/answers/programming/simple-design-questions-in-c/4384.html

malloc in C www.computing.net/answers/programming/malloc-in-c/8060.html

representing binary number in C www.computing.net/answers/programming/representing-binary-number-in-c/3346.html