I have the following code to create a big 2d array on the heap:
static unsigned char** storagebuffer;
storagebuffer = (unsigned char*) malloc(128 *sizeof(unsigned char *));
for (int i = 0; i < 128; i++)
storagebuffer[i] = malloc(8192 *sizeof(unsigned char));
This compiles and works OK using GCC
but when I do this in a Visual C++
file it gives the following errors:
processing.cpp(11): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>processing.cpp(11): error C2040: 'storagebuffer' : 'int' differs in levels of indirection from 'unsigned char **'
1>processing.cpp(11): error C2440: 'initializing' : cannot convert from 'unsigned char *' to 'int'
1> There is no context in which this conversion is possible
1>processing.cpp(13): error C2059: syntax error : 'for'
1>processing.cpp(13): error C2143: syntax error : missing ')' before ';'
1>processing.cpp(13): error C2143: syntax error : missing ';' before '<'
1>processing.cpp(13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>processing.cpp(13): error C2143: syntax error : missing ';' before '++'
1>processing.cpp(13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>processing.cpp(13): error C2086: 'int i' : redefinition
1> processing.cpp(13) : see declaration of 'i'
1>processing.cpp(13): error C2059: syntax error : ')'
How can I do this using Visual C++?