Linuxでgcc4.4.2を使用しています
gccがデフォルトでc99を最新の標準としてコンパイルするように自動的にデフォルト設定されるのだろうか?
c89またはc99のどちらでコンパイルするかを指定するにはどうすればよいですか?
アドバイスをありがとう、
デフォルトでC99を使用しない理由の1つは、この標準がまだコンパイラーに完全に実装されていないためです。ただし、gccをコンパイルするときにデフォルトのモードを設定できると思います。したがって、標準の選択が本当に重要な場合は、常にオプションを渡すことをお勧めします。
オプションはそれぞれ-std=c99
と-std=c89
です。
gcc(1)
マニュアルページから:
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
....
c99
c9x
iso9899:1999
iso9899:199x
ISO C99. Note that this standard is not yet fully supported;
see <http://gcc.gnu.org/gcc-4.4/c99status.html> for more
information. The names c9x and iso9899:199x are deprecated.
gnu89
GNU dialect of ISO C90 (including some C99 features). This is
the default for C code.
gnu99
gnu9x
GNU dialect of ISO C99. When ISO C99 is fully implemented in
GCC, this will become the default. The name gnu9x is
deprecated.