开发者

Getting the warning " ISO C90 forbids variable-size array" in gcc compiler while compiling C90 code

I am compiling my C90 c code in gcc . I am getting the warningISO C90 forbids variable-size array while making the declaration like

int symbols[nc];

Where nc is int开发者_JAVA技巧eger whose value is read from the input file. The values on the input files are varied so i can't keep a constant value. How can I get rid of it? Is it indeed necessary to resolve this warning or we can simply ignore it?

Thanks in advance.


You get that warning because C90 does not support variable length arrays.

You'll either have to switch gcc to C99 mode (which does support vla) , by using the -std=c99 or std=gnu99 command line flag, or rewrite your code to dynamically allocate memory or use a fixed size array.

The warning just tells you that you're not conforming to C90 in this case, but it's otherwise safe. Ignoring a warning should really not be an option though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜