yxl394766464 发表于 2011-3-22 15:44:13

请问ICCAVR支持链表吗?

请问ICCAVR支持链表吗?程序一直报错
#include <macros.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
//双链表结点接构
typedef struct DNodeType
{
    unsigned char tagaddr;
    struct DNodeType *next;
    struct DNodeType *prev;
}DNode;

//创建双链表
struct DNode * DoubleList(struct DNode *head)
{
    int i=0;
    if(NULL == head)//分配头节点空间
      head=(struct DNode*)malloc(sizeof(DNode)) ;
        head->prev=NULL ;
        head->next=NULL;
    struct DNode *current=head ;
        struct DNode *temp;
        DfReadOpen( 8000 );//读flash中链表区,即读取标签存放首地址,固定的
        DfRead( addr, 3 );
    while(1)
    {
      temp=(struct DNode *) malloc ( sizeof(DNode) );
      //temp->tagaddr= FouByts2U32(addr,addr,addr,addr);
                temp->tagaddr=text;
                i++;
      temp->next=NULL;
      current->next=temp;      /*当前节点的后驱指向新节点*/
      temp->prev=current;      /*新节点的前驱指向当前节点*/
      current=temp;            /*当前节点为链表尾节点*/
                if(temp->tagaddr == NULL)         /*结束输入*/
          break;
    }

    return head;
}

!E D:\LABDAT~1\AVR1280\program\flash1\main.c(23): undeclared identifier `tmp'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(47): unknown field `prev' of `incomplete struct DNode defined at D:\LABDAT~1\AVR1280\program\flash1\main.c(42)'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(48): unknown field `next' of `incomplete struct DNode defined at D:\LABDAT~1\AVR1280\program\flash1\main.c(42)'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(49): illegal statement termination
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(49): skipping `struct'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(49): illegal use of type name `DNode'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(49): undeclared identifier `current'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(49): operands of * have illegal types `struct DNodeType' and `int'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(49): operands of = have illegal types `int' and `pointer to incomplete struct DNode defined at D:\LABDAT~1\AVR1280\program\flash1\main.c(42)'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(49): lvalue required
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(50): illegal statement termination
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(50): skipping `struct'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(50): illegal use of type name `DNode'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(50): undeclared identifier `temp'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(50): operands of * have illegal types `struct DNodeType' and `int'
!W D:\LABDAT~1\AVR1280\program\flash1\main.c(50): expression with no effect elided
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(55): operands of = have illegal types `int' and `pointer to incomplete struct DNode defined at D:\LABDAT~1\AVR1280\program\flash1\main.c(42)'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(57): left operand of -> has incompatible type `int'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(59): left operand of -> has incompatible type `int'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(60): left operand of -> has incompatible type `int'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(61): left operand of -> has incompatible type `int'
!E D:\LABDAT~1\AVR1280\program\flash1\main.c(63): too many errors
错误都在链表建立这里,是不是头文件不对啊?请各路大侠指点!!

machao 发表于 2011-4-2 11:51:27

先学者把基本的错误找出改掉,比如第一个错误,恐怕与链表无关吧


!E D:\LABDAT~1\AVR1280\program\flash1\main.c(23): undeclared identifier `tmp'

skyhu 发表于 2011-4-2 12:09:52

C的基础没学好
typedef struct DNodeType
{
    unsigned char tagaddr;
    struct DNodeType *next;
    struct DNodeType *prev;
}DNode;

后面都是 struct DNode * ?

应该是 DNode *

yxl394766464 发表于 2011-4-5 18:28:15

谢谢了
页: [1]
查看完整版本: 请问ICCAVR支持链表吗?