-
wrote on 10 Jan 2022, 06:08 last edited by
int xc_init() { #define int intptr_t; int poolsize; // default size of text/data/stack int *text, poolsize = 1 * 1024; if (!(text = malloc(poolsize))) //error: assigning to 'intptr_t *' (aka 'int *') from incompatible type 'void *' return -1; }
here on malloc I get - error: assigning to 'intptr_t *' (aka 'int *') from incompatible type
-
int xc_init() { #define int intptr_t; int poolsize; // default size of text/data/stack int *text, poolsize = 1 * 1024; if (!(text = malloc(poolsize))) //error: assigning to 'intptr_t *' (aka 'int *') from incompatible type 'void *' return -1; }
here on malloc I get - error: assigning to 'intptr_t *' (aka 'int *') from incompatible type
@jenya7 Basic C/C++: malloc() returns void*, so cast it to int*
-
wrote on 10 Jan 2022, 06:50 last edited by
@jsulm said in Error allocating memory:
@jenya7 Basic C/C++: malloc() returns void*, so cast it to int*
I see. Thank you.
-
wrote on 15 Jan 2022, 06:36 last edited by
and you shouldn't use malloc() in c++ anyways.
const size_t intCount = 1000U;
int* intPtr = new int[intCount];
.
.
.
delete [] intPtr;
1/4