It is currently 16 Dec 2017 14:25

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 06 Dec 2017 15:51 
Offline

Joined: 27 Jun 2011 21:37
Posts: 21
I came across with a strange error

i declare a typedef struct with an array in it.
Then I initilize the struct and at the line of the array , I take Too many inializers error
typedef struct
{
  u8 Auto_Report_Flag;
  u8 First_Trigger_Type;
  u8 Second_Trigger_Type;
  char name[16];
} Control_Output;


 Control_Output control_Output  =
{
  /* u8 Auto_Report_Flag;   */ {OFF},
  /* u8 First_Trigger_Type; */ {CO_NO_ACTION},
  /* u8 Second_Trigger_Type;*/ {0},
  /* u8 name[16];           */ {1 ,2, 3,4,5,6,7,8,9,10,11,12,13,14,15,16}
};



 Control_Output control_Output  =
{
  /* u8 Auto_Report_Flag;   */ {OFF},
  /* u8 First_Trigger_Type; */ {CO_NO_ACTION},
  /* u8 Second_Trigger_Type;*/ {0},
  /* u8 name[16];           */ {"          "}
};



Top
 Profile  
 
PostPosted: 07 Dec 2017 03:22 
Offline

Joined: 24 Aug 2014 17:55
Posts: 93
Location: Sheffield
typedef struct
{
  u8 Auto_Report_Flag;
  u8 First_Trigger_Type;
  u8 Second_Trigger_Type;
  char name[16];
} Control_Output;




change to this

typedef struct
{
  char Auto_Report_Flag;
  char First_Trigger_Type;
  char Second_Trigger_Type;
  char name[16];
} Control_Output;


or declare this at top of your main c file

#define u8 unsigned char

_________________
"When the bugs strike it's no good bashing your head against a brick wall, you might damage the wall"


Top
 Profile  
 
PostPosted: 07 Dec 2017 10:29 
Offline

Joined: 27 Jun 2011 21:37
Posts: 21
typedef struct
{
  char Auto_Report_Flag;
  char Shedule_Action;
  char Every_Hour;
  char Every_Min;
  char enable_Flag;
} Shedule;


Shedule shedule =
{
   0,
   0,
   0,
   0,
   0
};



I am sorry , {} is the problem ,


Top
 Profile  
 
PostPosted: 07 Dec 2017 14:44 
Offline

Joined: 24 Jun 2007 19:27
Posts: 926
Location: 01120 Dagneux France
hello,

you don't show us, how do you assign value to the structure..
and it is a very bad habit to declare a new structure wit the original name of the structure
like this
Control_Output control_Output

Attachment:
Structure.jpg
Structure.jpg [ 94.61 KiB | Viewed 57 times ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: