Variable-length arrays in C89?

后端 未结 3 2052
野的像风
野的像风 2020-12-19 03:13

I\'ve read that C89 does not support variable-length arrays, but the following experiment seems to disprove that:

#include 

int main()
{
   i         


        
3条回答
  •  执念已碎
    2020-12-19 04:05

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

    Edit: In fact if you check here:

    http://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options

    Under -std= you will find the following:

    ISO C90 programs (certain GNU extensions that conflict with ISO C90 are disabled). Same as -ansi for C code.

    Pay close attention to the word "certain".

提交回复
热议问题