typedef struct _a_ { int *data; _a_() { data = (int *)mkl_malloc(10 * sizeof(int), 32); for (int i = 0; i < 10; i++) { data = i; } } ~_a_() { mkl_free(data); } }a_; int main(void) { a_ *b; b = (a_ *)mkl_malloc(10 * sizeof(a_), 32); std::cout << b[0].data[0] << std::endl; mkl_free(b); return 0; }
Link Copied
Jungmin,
I can't say for sure because I need to know what the error was and which line it refers to. You may be getting the error because you declared data as a pointer but are attempting to traverse it as if it were an array. If you tell me what the error is I can be more certain.
Pamela
For more complete information about compiler optimizations, see our Optimization Notice.