Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

c code problem - need explanation of errors

Status
Not open for further replies.

puneetnepsam

Junior Member level 3
Joined
Apr 27, 2009
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,478
c code problem

typedef struct __attribute__ ((packed))
{
unsigned char ser_time_out_flag:1;
unsigned char usb_time_out_flag:1;
unsigned char sms_time_out_flag:1;
unsigned char gprs_time_out_flag:1;
unsigned char wr_power_log_flag:1;
unsigned char sms_rx_flag:1;
}S_GLOBAL_FLAG;

typedef struct __attribute__ ((packed))
{
unsigned char rxd_byte_ctr;
unsigned char total_bytes;
unsigned char cmd_type;
unsigned char start_addr;
unsigned char cal_checksum;
unsigned char rxd_checksum;
unsigned char ack_nack_byte;
unsigned reception_start:1;
unsigned pro_data:1;
}S_SER_INFO;

typedef struct __attribute__ ((packed))
{
unsigned char CmdBuf[RCV_BUFFER_SIZE];

unsigned char SerCmdTotalByte;
unsigned SerRcvDataInFlag:1; // a global flag set when UART data Rcved
unsigned SerRcvCmdType :2; // CMD_GET or CMD_SET

unsigned char UsbCmdTotalByte;
unsigned UsbRcvDataInFlag:1; // a global flag set when USB data Rcved
unsigned UsbRcvCmdType :2; // CMD_GET or CMD_SET
}S_CMD_BUF_INFO;



after compiling this
following errors are coming:

serial.h:60: error: conflicting types for 'S_GLOBAL_FLAG'
serial.h:60: error: previous declaration of 'S_GLOBAL_FLAG' was here
serial.h:73: error: conflicting types for 'S_SER_INFO'
serial.h:73: error: previous declaration of 'S_SER_INFO' was here
serial.h:86: error: conflicting types for 'S_CMD_BUF_INFO'
serial.h:86: error: previous declaration of 'S_CMD_BUF_INFO' was here


can anyone please tell me why these errors are coming??
 

Re: c code problem

I think you included this header file twice unknowingly.

Use #ifdef concept to get rid of this error. hope you know this concept...else include the following code in your program...

#ifndef SERIAL_H
#define SERIAL_H

// content of your "Serial.h" file

#endif
 

Re: c code problem

not going man...
what r u trying to say...can you please write it in an example...
i have tried many times ....

Added after 2 minutes:

oh...#ifdef thing worked...

thanks @Varalakshmi
thanks for the help
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top