I have a function like this
void foo( int i) { ... uint8_t buf[ i]; ... }
and I don't understand why the compiler is not complaining... I'm using
g++ -c -g -Wallto compile
Any ideas??
I have a function like this
void foo( int i) { ... uint8_t buf[ i]; ... }
and I don't understand why the compiler is not complaining... I'm using
g++ -c -g -Wallto compile
Any ideas??
It is a GCC compiler extension. It is allowed by the standard for a conforming implementation because it does not break any well-formed code (as long as it issues a diagnostic). It is, of course, not portable and therefore not recommended.
With the -pedantic
option, you'll get the following warning:
warning: ISO C++ forbids variable length array ‘buf’ [-Wvla]