incomplete type is not allowed
keil环境下,报错#70: incomplete type is not allowed,解决
mqtt_conf.h 定义了一个结构体
mqtt_buffer.h
#include <stdint.h>
#include "mqtt.h"
定义了一个结构体
struct MqttBuffer
{
struct MqttExtent *first_ext;
struct MqttExtent *last_ext;
uint32_t available_bytes;
char **allocations;
char *first_available;
uint32_t alloc_count;
uint32_t alloc_max_count;
uint32_t buffered_bytes;
};
c.h
#include <stdint.h>
#include <time.h>
#include "mqtt_conf.h"
#include "mqtt_buffer.h"
定义了一个结构体
struct MqttSampleContext
{
uint32_t sendedbytes;
struct MqttBuffer mqttbuf[1];
struct MqttContext mqttctx[1];
const char *proid;
const char *devid;
const char *apikey;
int dup;
enum MqttQosLevel qos;
int retain;
uint32_t publish_state;
uint16_t pkt_to_ack;
char cmdid[MQTT_LEN_MAX];
};
编译报错如下:
..\User\mqtt.h(189): error: #70: incomplete type is not allowed
struct MqttBuffer mqttbuf[1];
搜索了很多文章,没有找到原因。
后来 受到下面这个链接的启发,原来在mqtt_buffer.h 多了#include "mqtt.h"。原来在a.h里的内容比较少,我将内容搬到mqtt.h里了,所以才加了这句。恢复回去,就好了。
http://zhidao.baidu.com/link?url=HTiXra-5HCPCfj0_VleRYX5s9aDKBLnZjRBOEahUDPMF6u2CYBJ2yuxlaXIZZfihkRl1eWPUJZE-9JAXcmzrZq
结论,#include 的文件之间最好是单向的关系。在功能划分的时候,应尽量避免这个问题。keil的c跟标准的c似乎有些区别,很多时候没用 extern关键字反而没啥问题。
incomplete type is not allowed的更多相关文章
- ifstream:incomplete type is not allowed
IntelliSense: incomplete type is not allowed ifstream inputFile; Need to add this: #include <fstr ...
- incomplete type is not allowed ofstream
错误: incomplete type is not allowed 解决方案: #include<fstream>
- keil中error: #70: incomplete type is not allowed—解决方法
今天在写程序的时候,想使用sizeof求数组的大小,数组中其他c文件定义,在头文件使用extern uint8_t buff_value[]; 声明 但是keil编译报错,网上查了,发现,需要写成ex ...
- 关于编译报错“dereferencing pointer to incomplete type...
今天同事问了我一个问题,他make的时候报错,“第201行:dereferencing pointer to incomplete type”,我随即查阅了很多资料,也没看出个所以然.最后问题得到了解 ...
- mysql编译时报的一个警告warning: type-punning to incomplete type might break strict-aliasing rules,可能是bug
cmake的时候报了一个警告: /softdb/mysql-5.5.37/storage/innobase/handler/ha_innodb.cc:11870: warning: type-punn ...
- 编译报错dereferencing pointer to incomplete type
关于编译报错“dereferencing pointer to incomplete type... 多是没找到结构体的定义,可以在本地复制其定义试试. 参考: http://my.oschina.n ...
- error: variable '__this_module' has initializer but incomplete type错误解决
版权所有,转载必须说明转自 http://my.csdn.net/weiqing1981127 原创作者:南京邮电大学 通信与信息系统专业 研二 魏清 问题描述:使用SAM9X25 内核版本是2. ...
- error “base class has incomplete type”
error "base class has incomplete type" 如果base.h是你的基类,那么在子类derive中,写成如下形式: class base; clas ...
- 错误:variable `xxx' has initializer but incomplete type
错误:variable `xxx' has initializer but incomplete type 原因:xxx对应的类型没有找到,只把xxx声明了但是没给出定义.编译器无从确认你调用的构造函 ...
随机推荐
- Static 单例模式
Static 方法的问题 今天在看EhCache源码的时候,发现有一个这样的方法 这个是个典型的单例模式的工具类,但我所知道的单例模式的写法不是这样的,虽然<effect java>中 ...
- Java自带的性能监测工具用法简介——jstack、jconsole、jinfo、jmap、jdb、jsta、jvisualvm
JDK内置工具使用 一.javah命令(C Header and Stub File Generator) 二.jps命令(Java Virtual Machine Process Status To ...
- 服务器如何防ssh服务暴力破解??
如图: 当我们遭到暴力破解ssh服务该怎么办 内行看门道 外行看热闹 下面教大家几招办法: 1 密码足够的复杂,密码的长度要大于8位最好大于20位.密码的复杂度是密码要尽可能有数字.大小写字母和特 ...
- 【Zookeeper】源码之序列化
一.前言 在完成了前面的理论学习后,现在可以从源码角度来解析Zookeeper的细节,首先笔者想从序列化入手,因为在网络通信.数据存储中都用到了序列化,下面开始分析. 二.序列化 序列化主要在zook ...
- SharePoint 2016 自定义城市和区域字段
前言 最近有这么一个需求,就是用到中国的各种行政区,然后还是三级联动,就琢磨写这么一个字段.然后,觉得挺有意义的,写字段的过程也有点心得,就想到拿到博客里分享给大家,一起看看. 1. 创建字段的解决方 ...
- 【Zookeeper】源码分析之持久化--FileSnap
一.前言 前篇博文已经分析了FileTxnLog的源码,现在接着分析持久化中的FileSnap,其主要提供了快照相应的接口. 二.SnapShot源码分析 SnapShot是FileTxnLog的父类 ...
- Server Tomcat v6.0 at localhost was unable to start within 45 seconds
在eclipse里启动tomcat的时候出现以下的错误: Server Tomcat v6.0 at localhost was unable to start within 45 seconds. ...
- 关于Ueditor 前后端分离实现文件上传到独立服务器的问题 望大神们赐教
最近,由于网站实现多台服务器负载均衡,导致编辑器上传文件需要同步,可是使用同步软件太慢,不太现实,所以想到实现编辑器上传文件直接上传到独立文件服务器.可是没想到遇到坑了. 1.在本地IIS 中添加网站 ...
- 一个简单的使用restc demo
最近不经意间看到饿了么团队开发的restc,接口调试工具(类似postman),其实调试接口都没用过工具,每次都只是运行起项目直接调接口.闲来无事,看到restc,就决定试试,后面觉得挺不错的,就分享 ...
- 五、RDD持久化
Spark最重要的一个功能是它可以通过各种操作(operations)持久化(或者缓存)一个集合到内存中.当你持久化一个RDD的时候,每一个节点都将参与计算的所有分区数据存储到内存中,并且这些数据可以 ...