ISO C90 forbids variable length array

前端 未结 6 1987
感动是毒
感动是毒 2020-12-09 23:14

I\'m dynamically calculating the size of an array. Something like:

void foo(size_t limit)
{
  char buffer[limit * 14 + 1];
}

But just GCC c

6条回答
  •  无人及你
    2020-12-10 00:11

    A const qualified variable is not an integer constant expression in the sense of the standard. This has to be a literal constant, an enumeration constant, sizeof or some expression composed with these.

    Switch to C99 if you may. The gcc option is -std=c99 (or gnu99 if you want gnu extension.)

提交回复
热议问题