我在 linux 上使用 gcc 4.4.2
我只是想知道 gcc 是否会自动默认以 c99 作为其最新标准进行编译?
如何指定是否要使用 c89 或 c99 编译?
非常感谢您的任何建议,
默认情况下不使用 C99 的一个原因是该标准尚未在编译器中完全实现。但是,我相信你可以在编译 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.