struct并不报错
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并不报错的更多相关文章
- VC中编译报错:error C2011: 'fd_set' : 'struct' type redefinition
这是头文件包含顺序的问题,原因与解决办法见下面代码的注释. /* 包含下面这两个头文件时,必须把winsock2.h放在前面 否则编译报错,N多的重定义错误:例如 error C2011: 'fd_s ...
- 编译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 ...
- python连接impala时,执行SQL报错expecting list of size 2 for struct args
这个错误困扰了好久,因为集群有多台,暂放到其他几台机器上执行了SQL操作,一直在找解决方法,无意间得到真传,喜出望外啊 报错信息: Traceback (most recent call last): ...
- 编译器报错: error LNK2001: unresolved external symbol "struct _ServiceDescriptorTable * KeServiceDescript
转自VC错误:http://www.vcerror.com/?p=10 问题描述: 编译器报错: error LNK2001: unresolved external symbol "str ...
- 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 ...
- Openwrt 编译报错:rootfs image is too big解决方法
修改: tools/firmware-utils/src/mktplinkfw2.c static struct flash_layout layouts[] = { { .id = "8M ...
- 关于编译报错“dereferencing pointer to incomplete type...
今天同事问了我一个问题,他make的时候报错,“第201行:dereferencing pointer to incomplete type”,我随即查阅了很多资料,也没看出个所以然.最后问题得到了解 ...
- 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> # ...
- 解决oralce 11g dg搭建报错:ORA-16664、ORA-16714、ORA-16810问题--转
下面不是小编错误报告只是转了网络一篇,同时也解决了我的问题所以复制过来给各位参考. 最近在弄11g的dg时,遇到如下问题,记录下.首先在主上查看报如下错误: DGMGRL> show confi ...
随机推荐
- [Golang] http.Post导致goroutine泄漏
记录一个用http.Post的问题 if _, err := http.Post("http://127.0.0.1:8080", "", nil); nil ...
- [转]Ubuntu18.04 主题美化以及常用软件
原文地址:https://www.jianshu.com/p/7d153a484f72
- spark 读写text,csv,json,parquet
以下代码演示的是spark读取 text,csv,json,parquet格式的file 为dataframe, 将dataframe保存为对应格式的文件 package com.jason.spar ...
- (转)mysql使用Navicat 导出和导入数据库
mysql使用Navicat 导出和导入数据库 ps:在导入本地数据库的时候,要先建立相同的数据库,然后再运行sql文件,即可导入相应的数据库
- [转帖]在VirtualBox Linux 7u2 中安装Oracle RAC 12.2.0.1.0
https://xiaoyu.blog.csdn.net/article/details/81980936
- asp.net中的html標籤runat=server時的映射
asp.net中的html控制項runat=server時的映射 1.標準xhtml標籤:http://blog.csdn.net/TangZhongxin/archive/2009/07/31/43 ...
- Java集合框架(Java总结五)
”https://www.runoob.com/java/” 集合接口区别 List 接口存储一组不唯一,有序(插入顺序)的对象,允许有相同的元素. Set 接口存储一组唯一,无序的对象,不保存重复的 ...
- 开灯问题—C语言
开灯问题 有n盏灯,编号为1~n.第1个人把所有灯打开,第2个人按下所有编号为2的倍数开关(这些灯将被关掉),第3个人按下所有编号为3的倍数的开关,以此类推.一共有k个人,问最后哪些灯是开着?输入n和 ...
- 1. Spark GraphX概述
1.1 什么是Spark GraphX Spark GraphX是一个分布式图处理框架,它是基于Spark平台提供对图计算和图挖掘简洁易用的而丰富的接口,极大的方便了对分布式图处理的需求.那么什么是图 ...
- RabbitMQ之消息模式(下)
目的: RabbitMQ之消息模式(上):https://www.cnblogs.com/huangting/p/11994539.html 消费端限流 消息的ACK与重回队列 TTL消息 死信队列 ...