编译给出错误,因为“数组'arr'的大小太大 [英] compilation giving error as "size of array ‘arr’ is too large

查看:652
本文介绍了编译给出错误,因为“数组'arr'的大小太大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



创建一个大小为data_node的静态数组arr [131072]。但是编译时我得到的错误是数组大小太大(gcc版本4.1.2 20070626(Red Hat 4.1.2-14))。



And data_node的大小约为972字节。在进行一些讨论时,我看到他们建议增加堆栈大小。现在我把它设置为无限制。





堆栈大小(kbytes,-s)无限

cpu time(seconds,-t)无限



任何建议。

Hi,
Am creating a static array of size data_node arr[131072]. But while compiling am getting the error as "array size is too large " (gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)) .

And the size of data_node is around 972 byte. While going through some discussion I saw they are suggesting about increasing the stack size. For now I have set it to unlimited.


stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited

Any suggestion.

推荐答案

如果是静态数组,堆栈大小没有被关注,因为它将被分配为程序的数据部分而不是堆栈。如果你不小心提到静态或意思是不通过alloc(..)那么这个解释可能是正确的。在那种情况下,我会建议使用头部。因此,通过

If it's a static array, stack size is not being concerned as it will be allocated as part of the data section of your program and not on the stack. If you however mentioned "static" just accidentally or meaning "not by alloc (..)" then this explanation might be right. In that case I would recommend to use the head anyway. So allocate it by
data_node* pNodes;
...
pNodes = alloc (sizeof (data_node) * 131072);
...
free (pNodes);


这篇关于编译给出错误,因为“数组'arr'的大小太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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