20

I couldn't disable it even though by using -std=c89 flag. How can I disable it?

Aykhan Hagverdili
  • 28,141
  • 6
  • 41
  • 93
Ricardo Cristian Ramirez
  • 1,194
  • 3
  • 20
  • 42

2 Answers2

29

You can generate an error for variable length arrays using a compiler flag:

-Werror=vla
Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
cauon
  • 473
  • 4
  • 9
2

Variable-length arrays in C89?

GCC always supported variable length arrays AFAIK. Setting -std to C89 doesn't turn off GCC extensions ...

See also:

https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html

http://tigcc.ticalc.org/doc/gnuexts.html#SEC76

Finally,

http://tigcc.ticalc.org/doc/gnuexts.html

'-pedantic' and other options cause warnings for many GNU C extensions. You can prevent such warnings within one expression by writing __extension__ before the expression. __extension__ has no effect aside from this.

Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • 5
    I'm not sure why this answer was accepted. The question was how to disable VLAs. @cauon's answer is the correct one. – Keith Thompson Apr 01 '17 at 19:42
  • 2
    It almost looks like the answer was written by some type of automated bot that just looks up random links and quotes related to the search term. – KANJICODER May 01 '20 at 10:41