error: #70: incomplete type is not allowed——已解决!
来源:互联网 发布:知乎 自己掏耳屎的方法 编辑:程序博客网 时间:2024/06/11 23:27
今天在使用sizeof与数组时总是编译出错,百思不得其解,折腾了半天问题终于解决了!现在此做点笔记,警醒自己也方便他人!
代码结构如下:
在某个c文件里定义并初始化了light_value[]这个数组,在另一个c文件要用到此数组,于是用extern声明如下:
extern u8 light_value[];
然后错误代码如下:
for (i=0; i<2; ++i)//合并2位数
{
n = i * 2;
light_value[sizeof(light_value)/sizeof(light_value[0]) - 2 + i]
= light_value[n]*10 + light_value[n+1];
}
问题当然就出在sizeof(light_value)上了,什么原因呢?
原来是用extern 声明 light_value[]时没有指明数组的大小(即长度),
如此sizeof就不知道light_value所占空间的大小了,所以编译器就报错了!
故:在extern u8 light_value[];中指明数组大小就行了,
如:extern u8 light_value[6];这样就不会报错了。
- error: #70: incomplete type is not allowed——已解决!
- keil中error: #70: incomplete type is not allowed——已解决!
- error: #70: incomplete type is not allowed——已解决!
- Error:incomplete type is not allowed
- incomplete type is not allowed
- C++ Class incomplete type is not allowed
- 前向声明之“Error: pointer to incomplete class type is not allowed.”
- 【C++】如何解决“pointer to incomplete class type is not allowed”。
- pointer to incomplete class type is not allowed是什么错误?
- pointer to incomplete class type is not allowed 错误
- [Builderror]pointer to incomplete class type is not allowed
- The processing instruction target matching "[xX][mM][lL]" is not allowed——已解决
- PCL 中 pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr 出现incomplete type is not allowed 的解决方法
- error: ‘to_string’ is not a member of ‘std’———已解决
- 【已解决】Object of type 'range' is not JSON serializable
- 【已解决】Object of type 'QuerySet' is not JSON serializable
- Error:Content is not allowed in prolog.
- 解决 has incomplete type
- [bzoj1503][NOI2004]郁闷的出纳员
- Android之AsyncTask(一)
- 用带参数的宏定义,通过海伦公式求三角形的面积
- 使用sqlldr命令向Oracle导入数据
- 我的第一篇博文
- error: #70: incomplete type is not allowed——已解决!
- 如何在外网中访问自己在另一个局域网中的某个机器(SSH为例)
- OS X Mavericks 10.9 Developer Preview 高速下载地址by lwxshow
- HTTP协议 (五) 代理
- 我所知的伟大人物
- C++ Singleton (单例) 模式最优实现
- 黑马程序员--第二十四天:网络编程第二天
- 深入了解scanf()/getchar()和gets()等函数
- C语言中的空指针、空指针常量、NULL_&_0