如何申报头部的extern二维数组? [英] How to declare extern 2d-array in header?

查看:546
本文介绍了如何申报头部的extern二维数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有这个声明在可见的lcd.c:

  unsigned char型LCD [8] [64] = {((unsigned char型)0)};

而在lcd.h用于我们想要的是这样的:

 的extern unsigned char型LCD [] [];

我们得到这个错误:

 错误[Pe098]:数组可能没有这种类型的元素


解决方案

您需要在最低限度,以包括一个2-D数组最右边的列大小。你可以声明它是这样的:

 的extern unsigned char型LCD [] [64];

否则,编译器将不能够计算的第一行之后的偏移

We have this declaration in LCD.c:

unsigned char LCD[8][64] = {((unsigned char) 0)};

And in LCD.h we want to have something like:

extern unsigned char LCD[][];

We get this error:

Error[Pe098]: an array may not have elements of this type

解决方案

You need, at a minimum, to include the right-most column size for a 2-D array. You can declare it like this:

extern unsigned char LCD[][64];

Otherwise the compiler would not be able to compute the offset after the first row.

这篇关于如何申报头部的extern二维数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆