GCC 編譯標準-std=的設置方法

1) 最初的 ANSI C 標準 (X3.159-1989) 在 1989 年被批准,並於 1990 年發佈。稍後這個標準被接受爲 ISO 標準 (ISO/IEC 9899:1990) 。雖然 ISO 標準將 ANSI 標準的某些章節重新編號並變爲條款,但是兩者實際上並無區別。不論是 ANSI 標準還是 ISO 標準,通常都稱之爲 C89 ,偶爾也因爲發佈日期而被叫做 C90 。 ANSI 標準 ( 非 ISO 標準 ) 同時附帶了 rationale 文檔。可以使用 -ansi , -std=c89 或 -std=iso9899:1990 選項指定 GCC 使用 C89 標準;可以使用 -pedantic 選項來得到所有的診斷信息( 或者使用 -pedantic-errors 選項以使 wangning 變爲 error) 。PS:pedantic adj. 1. 賣弄學問的 2. 學究式的,迂腐的

2) 新的 ISO C 標準是 1999 年發佈的 ISO/IEC 9899:1999 ,通常稱之爲 C99 。 GCC 目前不完整的支持這個版本。詳情請參考 http://gcc.gnu.org/gcc-4.4/c99status.html 。爲了指定 GCC 使用這個版本的 C 標準,需要 -std=c99 或 -std=iso9899:1999 選項。

3) 默認情況下, GCC 提供了一些 C 語言的擴展,極少的幾處會與 C 標準衝突。關於這些衝突請參考 “ C 語言家族的擴展 ” 一節。使用上述的 -std 選項將會關閉這些有衝突的擴展。你也可以顯式的使用選項 -std=gnu89 ( 對應 C89 的 GNU 擴展 ) 或 -std=gnu99 ( 對應 C99 的 GNU 擴展 ) 來選擇對應版本的擴展功能。如果沒有給出 C 語言 “ 方言 ” 選項,將默認的使用 -std=gnu89 ;若要使用C99的特性要設置-std=gnu9x。

4)-std= 選擇C語言編譯標準

-std=

A value for this option must be provided; possible values are

`c90'

`c89'

`iso9899:1990'

Support all ISO C90 programs (certain GNU extensions that conflict with ISO C90 are disabled). Same as -ansi for C code.

`iso9899:199409'

ISO C90 as modified in amendment 1.

`c99'

`c9x'

`iso9899:1999'

`iso9899:199x'

ISO C99. Note that this standard is not yet fully supported; see http://gcc.gnu.org/c99status.html for more information. The names `c9x' and `iso9899:199x' are deprecated.

`c1x'

ISO C1X, the draft of the next revision of the ISO C standard. Support is limited and experimental and features enabled by this option may be changed or removed if changed in or removed from the standard draft.

`gnu90'

`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.

`gnu1x'

GNU dialect of ISO C1X. Support is limited and experimental and features enabled by this option may be changed or removed if changed in or removed from the standard draft.

`c++98'

The 1998 ISO C++ standard plus amendments. Same as -ansi for C++ code.

`gnu++98'

GNU dialect of -std=c++98. This is the default for C++ code.

`c++0x'

The working draft of the upcoming ISO C++0x standard. This option enables experimental features that are likely to be included in C++0x. The working draft is constantly changing, and any feature that is enabled by this flag may be removed from future versions of GCC if it is not part of the C++0x standard.

`gnu++0x'

GNU dialect of -std=c++0x. This option enables experimental features that may be removed in future versions of GCC.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章