C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 3rd, 2012, 03:15 AM
lasm lasm is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2011
Posts: 21 lasm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 44 m 11 sec
Reputation Power: 0
C Compiler errors

Hi Guys,
I mainly write C programs for embedded applications, a few months back with some help from you I wrote a Usart communications program for the NXP LPC1443 that worked quite well.
I am now working with a new uProcessor and using a different IDE/compiler and when porting the program I am getting some errors that I did not get before. I tried to look at the issues but can not understand the errors that the compiler is throwing at me, Hence I need your help. I am sure this is because I am missing some C knowledge so please fell free to send me some links related to the subject.

Here is the header file that is giving me the errors:

Code:
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __BUFFERSTORE_H
#define __BUFFERSTORE_H

#define	NUMBEROFBUFFERS	20	

/*MultiBuffer Definition
 * This is the work horse of this program. it defines
 * storage for either data for processing, packet for
 * transmission or just received and also the raw data for
 * physical medium
 * These definition by using the union construct will allow
 * for easier data manipulation.
 */

typedef volatile union
{
	struct
	{
		/*	For data storage can be used for everything (TX or RX)	*/
		char processNumber;	/*	will probably id the task that needs the data	*/
		//char pNumberB;		/*	Packet number binary (one byte)	*/
		char dataSize;		/*	number of bytes(max 10)	*/
		char data[10];		/*	Data bytes	*/

	}dataS;	/*	Data structure	*/

	struct
	{
		/*	For Packet Storage can be used for RX or TX
			All values have been translated to Hex ASCII
			Hence the need for Two bytes in most cases.	*/
		char pStartChar;	//Start char normally (
		char pTypeChar;		//Packet Type 1 to F
		char pNumberH[2];	//packet number in Hex 00 to FF
		char pDSize[2];		//packet size in Hex 
		char pChecksum[2];	//packet checksum
		char pData[20];		//packet Data
		char pEndChar;		//End char normally )
		char pSize;
	}packetS;	// Packet structure
	
	struct
	{
		//for Packet Storage after Hex Ascii to binary conversion
		// may not be needed can be used for RX or TX
		//All values have been translated to Binary values
		char pStartChar;	//Start char normally (
		char pTypeChar;		//Packet Type 1 to F
		char pNumber;		//packet number in Hex 00 to 255
		char pDSize;		//packet size 
		char pChecksum;		//packet checksum 00 to FF
		char pData[10];		//packet Data
		char pEndChar;		//End char normally )
		
	//for raw hex data
	char rBuffer[30]; // this buffer is defined for ease of use by the UART
}MultiBuffer;

/* --------------------------------------------------------------------------- */


/* Queue Handling */

/*	The Element as two parts, the payload or data part
	and a pointer to the next Element, hence it can be used to
	implement a linked list. 									*/

typedef	volatile struct Element Element;	/*	This is required to let the compiler know
												that the struct Element is te same as the Element
												or it will generate an "incomplete" definition error. */

struct Element
{
	MultiBuffer *payload;
	volatile struct Element *nextElement;
};


/*	To implement a queue de only thing you need really is to know where the Head of 
	the Queue and its tail is. By then accessing the elements they will let you know 
	where the others are.																*/
volatile typedef struct
		{
			volatile Element *head;
			volatile Element *tail;
		}Queue;

/* ------------------------------------------------------------------------------------*/


volatile Queue *createQueue(void);
void createQueues(void);
volatile Queue *addElementToQueue(volatile Queue *queue, volatile MultiBuffer *bufferPrt);
volatile MultiBuffer *getElementFromQueue(volatile Queue *queue);
		
		
#endif /* __BUFFERSTORE_H */



On this line...

Code:
/*	The Element as two parts, the payload or data part 	and a pointer to the next Element, hence it can be used to 	implement a linked list. 									*/  typedef	volatile struct Element Element;	/*	This is required to let the compiler know 												that the struct Element is the same as the Element 												or it will generate an "incomplete" definition error. */


I get errors:
.\inc\bufferStore.h(98): error: #70: incomplete type is not allowed

and

.\inc\bufferStore.h(98): error: #80: a storage class may not be specified here


On this part of the code:

Code:
struct Element 
{ 	MultiBuffer *payload;
 	volatile struct     Element *nextElement; 
};


I get erros:

.\inc\bufferStore.h(104): error: #20: identifier "MultiBuffer" is undefined

and

.\inc\bufferStore.h(106): warning: #40-D: expected an identifier

The other errors are similar, if can find out what the problem is I can fix the rest.

Thank you in advance for any help.

Best Regards
Luis

Last edited by lasm : December 3rd, 2012 at 03:19 AM. Reason: Code Tags getting all the text inline.

Reply With Quote
  #2  
Old December 3rd, 2012, 05:52 AM
salem's Avatar
salem salem is online now
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,839 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 18 h 47 m 43 sec
Reputation Power: 1774
> }MultiBuffer;
Well the first problem seems to be that you're missing a closing brace around about here.

Next, cut down on the happy stick with the word 'volatile' written on it.
It makes no sense for example to declare a typedef as being volatile.

This compiles with gcc.
Code:
#define NUMBEROFBUFFERS 20  

/*MultiBuffer Definition
 * This is the work horse of this program. it defines
 * storage for either data for processing, packet for
 * transmission or just received and also the raw data for
 * physical medium
 * These definition by using the union construct will allow
 * for easier data manipulation.
 */

typedef /*volatile*/ union
{
  struct
  {
    /*  For data storage can be used for everything (TX or RX)  */
    char processNumber; /*  will probably id the task that needs the data */
    //char pNumberB;    /*  Packet number binary (one byte) */
    char dataSize;    /*  number of bytes(max 10) */
    char data[10];    /*  Data bytes  */

  }dataS; /*  Data structure  */

  struct
  {
    /*  For Packet Storage can be used for RX or TX
      All values have been translated to Hex ASCII
      Hence the need for Two bytes in most cases. */
    char pStartChar;  //Start char normally (
    char pTypeChar;   //Packet Type 1 to F
    char pNumberH[2]; //packet number in Hex 00 to FF
    char pDSize[2];   //packet size in Hex 
    char pChecksum[2];  //packet checksum
    char pData[20];   //packet Data
    char pEndChar;    //End char normally )
    char pSize;
  }packetS; // Packet structure
  
  struct
  {
    //for Packet Storage after Hex Ascii to binary conversion
    // may not be needed can be used for RX or TX
    //All values have been translated to Binary values
    char pStartChar;  //Start char normally (
    char pTypeChar;   //Packet Type 1 to F
    char pNumber;   //packet number in Hex 00 to 255
    char pDSize;    //packet size 
    char pChecksum;   //packet checksum 00 to FF
    char pData[10];   //packet Data
    char pEndChar;    //End char normally )
    
    //for raw hex data
    char rBuffer[30]; // this buffer is defined for ease of use by the UART
  } foo;  //!! pick a name for this nested struct
}MultiBuffer;

/* --------------------------------------------------------------------------- */


/* Queue Handling */

/*  The Element as two parts, the payload or data part
  and a pointer to the next Element, hence it can be used to
  implement a linked list.                  */

#if 0
//!! serves no purpose.
//!! you probably added this to 'fix' the missing earlier brace.
typedef volatile struct Element Element;  /*  This is required to let the compiler know
                        that the struct Element is te same as the Element
                        or it will generate an "incomplete" definition error. */
#endif

struct Element
{
  MultiBuffer *payload;
  volatile struct Element *nextElement;
};


/*  To implement a queue de only thing you need really is to know where the Head of 
  the Queue and its tail is. By then accessing the elements they will let you know 
  where the others are.                               */
/*volatile*/ typedef struct
    {
      //!! you need struct Element here, because Element isn't typedef'ed
      volatile struct Element *head;
      volatile struct Element *tail;
    }Queue;

/* ------------------------------------------------------------------------------------*/


volatile Queue *createQueue(void);
void createQueues(void);
volatile Queue *addElementToQueue(volatile Queue *queue, volatile MultiBuffer *bufferPrt);
volatile MultiBuffer *getElementFromQueue(volatile Queue *queue);
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > C Compiler errors

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap