Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
GCC は次の関数をコンパイルします
void f(int i) { int a[i]; }
配列は一定の長さでしか初期化できないという印象を受けました。これはコンパイルすることになっていて、期待どおりに動作しますか?
C99 では可変長配列が追加されました。そしてgcc、これをオプション付きの拡張子として c89 に追加し -std=gnu89ます (デフォルトではgcc)。
gcc
-std=gnu89
最新の C 標準である C11 では、可変長配列のサポートはオプションとしてマークされています。
VLA は C99 で許可されています。GCC 拡張により、C89 モードでコンパイルできます。