int * const front = mmap(0, sizeof(int), PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
int * const back = mmap(0, sizeof(int), PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
int * const buffer = mmap(0, sizeof(int)*50, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
I am getting the following error: "error: initializer element is not constant"
How do I remove it?
I know it won't work if I do something like int a[b];
, but why is it happening here?
You haven't said, but it's pretty likely that you're working in C, not C++, and that these are variables with static duration? In C, you can only intialize a static variable with something that is a compile-time constant expression. A function-call is not a compile-time constant expression.