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的更多相关文章

  1. ifstream:incomplete type is not allowed

    IntelliSense: incomplete type is not allowed ifstream inputFile; Need to add this: #include <fstr ...

  2. incomplete type is not allowed ofstream

    错误: incomplete type is not allowed 解决方案: #include<fstream>

  3. keil中error: #70: incomplete type is not allowed—解决方法

    今天在写程序的时候,想使用sizeof求数组的大小,数组中其他c文件定义,在头文件使用extern uint8_t buff_value[]; 声明 但是keil编译报错,网上查了,发现,需要写成ex ...

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

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

  5. 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 ...

  6. 编译报错dereferencing pointer to incomplete type

    关于编译报错“dereferencing pointer to incomplete type... 多是没找到结构体的定义,可以在本地复制其定义试试. 参考: http://my.oschina.n ...

  7. error: variable '__this_module' has initializer but incomplete type错误解决

    版权所有,转载必须说明转自 http://my.csdn.net/weiqing1981127 原创作者:南京邮电大学  通信与信息系统专业 研二 魏清 问题描述:使用SAM9X25  内核版本是2. ...

  8. error “base class has incomplete type”

    error "base class has incomplete type" 如果base.h是你的基类,那么在子类derive中,写成如下形式: class base; clas ...

  9. 错误:variable `xxx' has initializer but incomplete type

    错误:variable `xxx' has initializer but incomplete type 原因:xxx对应的类型没有找到,只把xxx声明了但是没给出定义.编译器无从确认你调用的构造函 ...

随机推荐

  1. [每日一题] OCP1z0-047 :2013-07-19 Rules of Precedence――括号的使用

    这道题目的意思是你的公司决定给所有呆到5年或5年以上的所有员工每个月加50美元,然后算出总的年薪.每个月薪水:salary,每个月加到:salary+50,总的年薪: (salary+50)*12. ...

  2. Unable to start T-SQL Debugging. Could not connect to the computer ‘.’

    Unable to start T-SQL Debugging. Could not connect to the computer ‘.’ 在Win7上面使用SSMS连接到SQL Server使用D ...

  3. data矩阵poj 2778 DNA Sequence

    最近研究data矩阵,稍微总结一下,以后继续补充: ac自动机处理字符串,dp计算谜底,用矩阵来减速     每日一道理 巴尔扎克说过“不幸,是天才的进升阶梯,信徒的洗礼之水,弱者的无底深渊”.风雨过 ...

  4. X86 IO端口和MMIO

    X86 IO端口和MMIO I/O作为CPU和外设交流的一个渠道,主要分为两种,一种是Port I/O,一种是MMIO(Memory mapping I/O).前者就是我们常说的I/O端口,它实际上的 ...

  5. TCP/IP传输层,你懂多少?

    1. 传输层的主要功能是什么?2. 传输层如何区分不同应用程序的数据流?3. 传输层有哪些协议?4. 什么是UDP协议?5. 为什么有了UDP,还需要TCP?6. 什么是TCP协议?7. 怎么理解协议 ...

  6. linux面试题集锦3《转》

    三.简答题: 1.简述Linux文件系统通过i节点把文件的逻辑结构和物理结构转换的工作过程. 参考答案: Linux通过i节点表将文件的逻辑结构和物理结构进行转换. i节点是一个64字节长的表,表中包 ...

  7. 实际开发中,后台回传的错误格式的Json数据处理

    现在很多学习刚学习移动开发的同学,相信在培训机构,拿到后台数据的时候,格式都是正确的,甚至有的还是plist文件.但是实际开发中,我们获取数据都是通过网络接口从服务器获取数据,这些数据的格式都是后台写 ...

  8. 自定义Dialog,从下面弹出

    Window window= getWindow(); 只要 打开一个Activity 就有一个窗口存放这个Activity ,手机又很多个窗口,不只是一个窗口 import android.app. ...

  9. 读书笔记之《The Art of Readable Code》

    <The Art of Readable Code>- Dustin Boswell, Trevor Foucher    O'Reilly出版 整体认知:这本书写得很好,每一章后面的总结 ...

  10. SQL总结之导入导出

    (5)还原数据库[倒库] [数据泵模式]先要在D盘创建个目录,如D:/dbback 然后去plsql中创建目录sql命令:create directory dbback as 'D:\dbback'; ...