我在Linux上使用gcc 4.4.2用c89和c99编译gcc 4.4.2默认为c99吗?
我只是想知道gcc是否自动默认编译为c99作为其最新的标准?
如何指定我是否想用c89或c99进行编译?
非常感谢任何建议,
我在Linux上使用gcc 4.4.2用c89和c99编译gcc 4.4.2默认为c99吗?
我只是想知道gcc是否自动默认编译为c99作为其最新的标准?
如何指定我是否想用c89或c99进行编译?
非常感谢任何建议,
一个理由不使用默认C99是因为这个标准是不是完全在编译器实现的呢。不过,我相信你可以在编译gcc时设置默认模式,所以如果标准的选择对你真的很重要,最好总是通过选项。
选项分别为-std=c99
和-std=c89
。
我通常使用c89进行编译,因为它更便于携带。但是我喜欢c99的一些功能。但是,我不能使用c99标准,因为我需要在使用VS的windows上编译,而VS只支持c89。即使最新版本的VS 2010也不会实现c89。 – ant2009
如果我检查[GCC C99status](https://gcc.gnu.org/c99status.html),我找不到任何会影响大多数用例的缺失功能。你可以举一个可以阻止使用C99编译的缺失功能的例子吗? –
@RuudAlthuizen这个答案是在2010年编写的。截至2016年,据我所知,只有浮点专家方面缺失。 “
从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.
默认值依然gnu89(即C89和GNU扩展)。 –