Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 找不到变量的空间(120字节)_C++_C_Arrays_Int_Pic - Fatal编程技术网

C++ 找不到变量的空间(120字节)

C++ 找不到变量的空间(120字节),c++,c,arrays,int,pic,C++,C,Arrays,Int,Pic,我有一个定义了60个十六进制值的数组 int ary[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31, 0x32, 0x33,

我有一个定义了60个十六进制值的数组

int ary[] = {
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
    0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 
    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 
    0x47, 0x48, 0x49, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59 
};  
当我编译这个时,我得到了错误

could not find space (120 bytes) for variable _ary

为什么会发生这种情况,这是一个PIC程序,我需要数组的类型为
int
。我能做什么呢?

你需要把它作为一个字节来保存,为什么要把它存储为一个整数呢?你也可以在以后需要的时候把它转换成一个整数。而且,数字的顺序看起来很容易预测。它们不能动态生成吗?如果您的目标是一个具有(比如)80字节库的部件,则无法创建一个120字节的连续数组。“为什么会发生这种情况”是因为您的PIC没有足够的空间来存储常量数据。另外,您不需要将数组存储为
int
。改用
带符号字符
。您可以尝试声明它
常量
(常量整数[]),除非您需要在运行时更改值,一些pic编译器可能会将其放在另一种内存中(可能有也可能没有所需的空间)。