搜索
bottom↓
回复: 3

请问ICCAVR支持链表吗?

[复制链接]

出0入0汤圆

发表于 2011-3-22 15:44:13 | 显示全部楼层 |阅读模式
请问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[i+1],addr[i+2],addr[i+3]);
                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):[warning] 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
错误都在链表建立这里,是不是头文件不对啊?请各路大侠指点!!

阿莫论坛20周年了!感谢大家的支持与爱护!!

如果想吃一顿饺子,就得从冰箱里取出肉,剁馅儿,倒面粉、揉面、醒面,擀成皮儿,下锅……
一整个繁琐流程,就是为了出锅时那一嘴滚烫流油的热饺子。

如果这个过程,禁不住饿,零食下肚了,饺子出锅时也就不香了……《非诚勿扰3》

出0入0汤圆

发表于 2011-4-2 11:51:27 | 显示全部楼层
先学者把基本的错误找出改掉,比如第一个错误,恐怕与链表无关吧


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

出0入0汤圆

发表于 2011-4-2 12:09:52 | 显示全部楼层
C的基础没学好
typedef struct DNodeType
{
    unsigned char tagaddr;
    struct DNodeType *next;
    struct DNodeType *prev;
}DNode;

后面都是 struct DNode * ?

应该是 DNode *

出0入0汤圆

 楼主| 发表于 2011-4-5 18:28:15 | 显示全部楼层
谢谢了
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-3-28 22:29

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表