I guess my question is whether the following is valid C
int main(void) {
int r = 3;
int k[r];
return 0;
}
If so, would some one care to explain why it does not work in Microsoft's C compiler, but in GCC, and when it was added to the C standard.
Thank you
Safe and useful variable length arrays It's convenient and useful because it makes some expressions simpler. It's safe because there's no arbitrary stack allocation. Pointers to arrays are a rare sight in C code, whether variable length or not.
Variable-size data is data whose size is not known at compile time or whose size can change at run time.
Default. C90 and Standard C++ do not support variable length arrays by default. Select the option --vla to enable support for variable length arrays in C90 or Standard C++. Variable length arrays are supported in Standard C.
It is in C99. MSVC only supports C89.
The C99 standard added variable-length arrays, but other vendors such as GCC added them much earlier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With