【发布时间】:2017-05-09 02:46:25
【问题描述】:
我有以下代码:
#include <bits/stdc++.h>
using namespace std;
const int MAX=25;
const int TMAX=1 << MAX - 1;
double D[TMAX][MAX];
int main(){}
如果我编译它,我会得到
champ@champ-S451LN:~/code$ g++ kike2.cpp
/tmp/ccuK5NOq.o: In function `__static_initialization_and_destruction_0(int, int)':
kike2.cpp:(.text+0x717): relocation truncated to fit: R_X86_64_PC32 against `.bss'
kike2.cpp:(.text+0x72a): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: error: ld returned 1 exit status
如果我设置 MAX=22,我没有收到此错误,我认为问题在于 TMAX*MAX 超过 2^32。
访问如此大的二维数组对我很有用。有人知道怎么做吗?
这是我最后所做的:
#include <bits/stdc++.h>
using namespace std;
double** D = new double*[TMAX];// this is the DP array (its big so we save it differently)
int main(){
for(int i = 0; i < TMAX; ++i){// store the big array
D[i] = new double[MAX];
}
}
【问题讨论】:
-
在我的 ubuntu 15.10 上,pthread_attr_getstacksize() 将线程的堆栈大小报告为 8 MBytes。