This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

create variable length array

hello, i need to create variable length array. If i try to create this, i have infinite or empty array. I know that variable length array(vla) work after c99, but in documentation written that can be added --vla flag. I used c90 and --vla flag (option for target->c/c++>misc controls) and have error " --vla is underfinded". I tried use c99 standart where vla included, and i have empty (without length) array. If i use length variable from define or use int bytes[5] directly i have correct result. But i can not use define all time, because i need variable array. In eclipse it works, in keil with different standarts and versions of compiler i can't create variable length array.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "stdlib.h"
#define k 5
int main(void)
{
int i;
int ind=0;
for (i=0;i<=5;i++){
ind=i;
}
int bytes[ind]; //work if k or 5 or 0x05
return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

0