|
|
View previous topic :: View next topic |
Author |
Message |
pirklg
Joined: 20 Jul 2006 Posts: 1
|
CCS PCH C Compiler 3.223 Problem with linkedlist |
Posted: Thu Jul 20, 2006 1:41 am |
|
|
Hi,
I am doing my diploma thesis at the moment. I am implementing a location system usin PIC Processors.
Received information has to be stored dynamically in a linked list (at the beginning - later a search tree should be therefore used).
Usually a linked list shouldn't be the problem, I already got the linked list running using the gcc compiler.
Here is the Code:
nlist.h:
Code: | typedef struct listnode{
float x;
float y;
float z;
byte id[8];
unsigned int hop;
float distance;
} ElementType;
typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;
List MakeEmpty( List L );
int IsEmpty( List L );
int IsLast( Position P, List L );
Position Find( ElementType X, List L );
void Delete( ElementType X, List L );
Position FindPrevious( ElementType X, List L );
void Insert( ElementType X, List L, Position P );
void DeleteList( List L );
Position Header( List L );
Position First( List L );
Position Advance( Position P );
ElementType Retrieve( Position P ); |
nList.c:
Code: |
#include "nList.h"
#include <stdlibm.h>
#include <stddef.h>
struct Node
{
ElementType Element;
struct Node *Next;
};
List MakeEmpty( List L )
{
L = malloc( sizeof( struct Node ) );
//if( L == NULL )
//FatalError( "Out of memory!" );
L->Next = NULL; //<-------------- ERROR
return L;
} |
But with CCS C Compiler i got this strange error message:
Line 22 -> Expecting a structure / union.
The CCS Compiler defines NULL as 0 - this is the problem - how should I implement the linked list?
Any hints are wellcome.
Thanks for your Help,
Gerald |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jul 20, 2006 4:04 pm |
|
|
I worked on your problem a little bit yesterday, but don't have a
conclusion for you. I don't have PCH vs. 3.223. The closest I have
to that is vs. 3.230. I installed it, and was able to duplicate your
problem.
I then installed PCH vs. 3.249, and the compiler doesn't give any
error messages with that version.
I tried to find a work-around, so it would work with your earlier version.
I tried to cast the NULL to a 'List' data type, but that didn't work.
I tried using a variable of type 'List', instead of NULL, and that didn't
work either. At that point, I gave up. It could be that a work-around
is possible, but the other choice is to upgrade the compiler. |
|
|
|
|
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 vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|