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 ...
随机推荐
- ["Visual Studio快捷键" ,"Vs","IDEA快捷键"]
描述说明 描述 说明 ↑ 方向键.上 ↓ 方向键.下 ← 方向键.左 → 方向键.右 快捷键大比拼 描述 Visual Studio 快捷键 IDEA快捷键 VisualStudio学名 IDEA学名 ...
- Laravel实现from的curl文件转发
文件的使用curl分发时发现不能直接将其传入curl,需要使用CURLFile()来实现 分发类 <?php /** * 请求转发控制器 * Created by PhpStorm. * Use ...
- mysql全量+增量备份脚本
cat xtrabackup_mysql.sh #!/bin/bash #title :xtrabackup_mysql.sh #description :backup mysql by using ...
- Data-Structure-Notes
Data Structure Notes Chapter-1 Sorting Algorithm Selection Sorting: /* * Selection Sort */ template& ...
- 递归实现全排列python
python递归实现"abcd"字符串全排列 1.保持a不动,动bcd 2.保持b不动,动cd 3.保持c不动,动d def pailie(head="",st ...
- Python实现欧几里得算法
欧几里得算法的目标是找到两个数的最大公约数. 计算两个非负整数p和q的最大公约数:若q是0,则最大公约数为p.否则,将p除以q得到余数r,p和q的最大公约数即为q和r的最大公约数. def eucli ...
- Golang资料集
<Platform-native GUI library for Go> 介绍:跨平台的golang GUI库,支持Windows(xp以上),Unix,Mac OS X(Mac OS X ...
- C#月份和日期转大写和C#集合分组
//日转化为大写 private static string DaytoUpper(int day, string type) { if (day < 20) { return MonthtoU ...
- 高并发场景下System.currentTimeMillis()的性能问题的优化
高并发场景下System.currentTimeMillis()的性能问题的优化 package cn.ucaner.alpaca.common.util.key; import java.sql.T ...
- .net core 读取、修改配置文件appsettings.json
.net core 设置读取JSON配置文件 appsettings.json Startup.cs 中 public class Startup { public Startup(IHostingE ...