我在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.