How can I work around the Visual Studio Visual C #C2148 error? Here is the code that produces the error:
#define ACOUNT 2000
#define BCOUNT 9000
#define CCOUNT 195
struct s_ptx {
int pvCount[ACOUNT][BCOUNT][CCOUNT];
} ;
This produces a VStudio 2010 Visual C (compiling under 64bit) error #C2148: error C2148: total size of array must not exceed 0x7fffffff bytes
I know I could dynamically allocate the pvCount 3d array, but then I'd have to do a zillion alloc's and free's. I have 192 gig of memory, so I'm trying to find a compiler switch or option that allows something of this size.
Edit: The complicating issue I left out trying to simplify things is that ptx is a pointer that at runtime is used as an array of structs:
ptx *Ptx = (ptx *) calloc(10, sizeof(ptx));
for (int i = 0; i < 10; ++i)
{
Ptx->pv = (int (*)[BCOUNT][CCOUNT] ) malloc( (unsigned long) ACOUNT * BCOUNT *CCOUNT * sizeof(int));
}
for (int jav = 0; jav < 10; ++jav)
for (int j = 0; j < ACOUNT; ++j)
for (int k = 0; k < BCOUNT; ++k)
for (int m = 0; m < CCOUNT; ++m)
Ptx[jav].pv[j][k][m] = j + k + m;
So when I run the code I get an access violation error, presumably because by doing the dynamic allocation I am no longer able to use: Ptx[jav].pv[j][k][m]