struct {
int item;
struct list* next;
}list;

如果结构体定义如上,使用下面的代码,将会报错

//添加元素,由于我们实现的是单向链表,所以使用从尾部添加
bool AddItem(int a,struct list *plist)
{
struct list *pNew;
struct list *pNode;
pNode=plist;
pNew=malloc(sizeof( struct list));
if(pNew==NULL)
{
return false;
}
pNew->item=a;
pNew->next=NULL;
if(pNode==NULL)
{
plist=pNew;
}else
{
while(pNode->next!=NULL)
{
pNode=pNode->next;
}
pNode->next=pNew;
}
return true;
}

  

c30.c: In function 'AddItem':
c30.c:30:22: error: invalid application of 'sizeof' to incomplete type 'struct list'
pNew=malloc(sizeof( struct list));
^
c30.c:35:6: error: dereferencing pointer to incomplete type
pNew->item=a;
^

其报错并不在struct处,而是在其使用处。

这是因为结构体定义有问题。

struct并不报错的更多相关文章

  1. VC中编译报错:error C2011: 'fd_set' : 'struct' type redefinition

    这是头文件包含顺序的问题,原因与解决办法见下面代码的注释. /* 包含下面这两个头文件时,必须把winsock2.h放在前面 否则编译报错,N多的重定义错误:例如 error C2011: 'fd_s ...

  2. 编译binutil包报错 error: array type has incomplete element type extern const struct relax_type md_relax_table[];

    安装lfs时编译binutils出错: ../../sources/binutils-2.15.91.0.2/gas/config/tc-i386.h:457:32: error: array typ ...

  3. python连接impala时,执行SQL报错expecting list of size 2 for struct args

    这个错误困扰了好久,因为集群有多台,暂放到其他几台机器上执行了SQL操作,一直在找解决方法,无意间得到真传,喜出望外啊 报错信息: Traceback (most recent call last): ...

  4. 编译器报错: error LNK2001: unresolved external symbol "struct _ServiceDescriptorTable * KeServiceDescript

    转自VC错误:http://www.vcerror.com/?p=10 问题描述: 编译器报错: error LNK2001: unresolved external symbol "str ...

  5. php5.6.11编译安装报错configure: error: Don't know how to define struct flock on this system

    centos 6.8 32位系统下,安装php.5.6.11是出现这个错误 解决办法: 1 2 3 4 vim /etc/ld.so.conf.d/local.conf     # 编辑库文件 /us ...

  6. Openwrt 编译报错:rootfs image is too big解决方法

    修改: tools/firmware-utils/src/mktplinkfw2.c static struct flash_layout layouts[] = { { .id = "8M ...

  7. 关于编译报错“dereferencing pointer to incomplete type...

    今天同事问了我一个问题,他make的时候报错,“第201行:dereferencing pointer to incomplete type”,我随即查阅了很多资料,也没看出个所以然.最后问题得到了解 ...

  8. Ubuntu gcc编译报错:format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__time_t’ [-Wformat=]

    平时用的都是Centos系统,今天偶然在Ubuntu下编译了一次代码,发现报错了: 源码: #include <stdio.h> #include <sys/time.h> # ...

  9. 解决oralce 11g dg搭建报错:ORA-16664、ORA-16714、ORA-16810问题--转

    下面不是小编错误报告只是转了网络一篇,同时也解决了我的问题所以复制过来给各位参考. 最近在弄11g的dg时,遇到如下问题,记录下.首先在主上查看报如下错误: DGMGRL> show confi ...

随机推荐

  1. jmeter—建立测试计划

    一个测试计划描述了一系列 Jmeter 运行时要执行的步骤.一个完整的测试计划包含 一个或者多个线程组,逻 辑控制,取样发生控制,监听器,定时器,断言和配置元件. 一. 建立测试计划 在这一部分,你将 ...

  2. Arch Linux 启用 MTU 探测

    最近在家里经常遇到 ssh 超时的问题,一开始也没太当回事,感觉是网络不稳定导致的,但是后来慢慢的发现这种超时问题只会出现在跟 ssh 相关的程序中,例如 git.ssh.这成功的引起了我的注意,于是 ...

  3. Docker Compose 部署Nginx服务实现负载均衡

    Compose简介: Compose是Docker容器进行编排的工具,定义和运行多容器的应用,可以一条命令启动多个容器,使用Docker Compose,不再需要使用shell脚本来启动容器.Comp ...

  4. Python鼠标模拟

    有时候我们需要使用python执行一些脚本,可能需要让程序自动按键或自动点击鼠标,下面的代码实现了对键盘的模拟按键, 需要安装pypiwin32,当然也可以直接用ctypes来实现. 输入:pip i ...

  5. shell 编写脚本批量Ping IP

    服务器总是一下子买了很多的段的ip.通过绑定后,也不知道这些ip是否绑定成功,所以就写了一个shell脚本,把ip输好,批量ping一下,看是不是都能ping通. 脚本如下: 此外.还有一个ip文件, ...

  6. OI总结

    当下考的钟声叮当响起,该走了,一年半的OI竞赛就此结束 留下了很多遗憾.也拥有过一段美好的竞赛生活 结识了一群优秀的OI战友,一起进步一起开心一起忧愁,但这一切的一切都将在今晚变成过去式,CSp的好与 ...

  7. TCP/IP学习笔记1--概述,分组交换协议

    1.TCP/IP 互联网是由许多独立发展的网络通信技术融合而成的,能够使它们不断融合并实现统一的正式TCP/IP技术,TCP/IP使通信协议的统称. TCP/IP协议模型(Transmission C ...

  8. identity 基础表没有创建 aspnetuserclaims aspnetuserlogins

    protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuild ...

  9. GitBook的使用

    首先安装gitbook npm install -g gitbook-cli 检查是否安装成功 gitbook -V 然后就要建立一个文件夹进到文件夹目录下 让此文件夹初始化下 gitbook ini ...

  10. Python的基本数据类型2

    1.str(字符串) 1.切片 str = "你好,我是Python" s = str[0:4] #用法[start:end:step],指定开始下标和结束下标,step是步长,默 ...