GCC的文档

 

https://gcc.gnu.org/releases.html
各个版本下的gcc.pdf,可以细致了解里面的内容

  

地址规则:

https://gcc.gnu.org/onlinedocs/11.2.0/

ReleaseRelease date文档地址
GCC 9.5 May 27, 2022 https://gcc.gnu.org/onlinedocs/gcc-9.5.0/gcc.pdf
GCC 12.1 May 6, 2022 https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gcc.pdf
GCC 11.3 April 21, 2022 https://gcc.gnu.org/onlinedocs/gcc-11.3.0/gcc.pdf
GCC 11.2 July 28, 2021 https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc.pdf
GCC 9.4 June 1, 2021 https://gcc.gnu.org/onlinedocs/gcc-9.4.0/gcc.pdf
GCC 8.5 May 14, 2021 https://gcc.gnu.org/onlinedocs/gcc-8.5.0/gcc.pdf
GCC 11.1 April 27, 2021 https://gcc.gnu.org/onlinedocs/gcc-11.1.0/gcc.pdf
GCC 10.3 April 8, 2021 https://gcc.gnu.org/onlinedocs/gcc-10.3.0/gcc.pdf
GCC 10.2 July 23, 2020 https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc.pdf
GCC 10.1 May 7, 2020 https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc.pdf
GCC 9.3 March 12, 2020 https://gcc.gnu.org/onlinedocs/gcc-9.3.0/gcc.pdf
GCC 8.4 March 4, 2020 https://gcc.gnu.org/onlinedocs/gcc-8.4.0/gcc.pdf
GCC 7.5 November 14, 2019 https://gcc.gnu.org/onlinedocs/gcc-7.5.0/gcc.pdf
GCC 9.2 August 12, 2019 https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc.pdf
GCC 9.1 May 3, 2019 https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc.pdf
GCC 8.3 February 22, 2019 https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc.pdf
GCC 7.4 December 6, 2018 https://gcc.gnu.org/onlinedocs/gcc-7.4.0/gcc.pdf
GCC 6.5 October 26, 2018  https://gcc.gnu.org/onlinedocs/gcc-6.5.0/gcc.pdf
GCC 8.2 July 26, 2018  https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc.pdf
GCC 8.1 May 2, 2018  https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc.pdf
GCC 7.3 January 25, 2018  https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc.pdf
GCC 5.5 October 10, 2017  https://gcc.gnu.org/onlinedocs/gcc-5.5.0/gcc.pdf
GCC 7.2 August 14, 2017  https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc.pdf
GCC 6.4 July 4, 2017  https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc.pdf
GCC 7.1 May 2, 2017  
GCC 6.3 December 21, 2016  
GCC 6.2 August 22, 2016  
GCC 4.9.4 August 3, 2016  
GCC 5.4 June 3, 2016  
GCC 6.1 April 27, 2016  
GCC 5.3 December 4, 2015  
GCC 5.2 July 16, 2015  
GCC 4.9.3 June 26, 2015  
GCC 4.8.5 June 23, 2015  
GCC 5.1 April 22, 2015  
GCC 4.8.4 December 19, 2014  
GCC 4.9.2 October 30, 2014  
GCC 4.9.1 July 16, 2014  
GCC 4.7.4 June 12, 2014  
GCC 4.8.3 May 22, 2014  
GCC 4.9.0 April 22, 2014  
GCC 4.8.2 October 16, 2013  
GCC 4.8.1 May 31, 2013  
GCC 4.6.4 April 12, 2013  
GCC 4.7.3 April 11, 2013  
GCC 4.8.0 March 22, 2013  
GCC 4.7.2 September 20, 2012  
GCC 4.5.4 July 2, 2012  
GCC 4.7.1 June 14, 2012  
GCC 4.7.0 March 22, 2012  
GCC 4.4.7 March 13, 2012  
GCC 4.6.3 March 1, 2012  
GCC 4.6.2 October 26, 2011  
GCC 4.6.1 June 27, 2011  
GCC 4.3.6 June 27, 2011  
GCC 4.5.3 April 28, 2011  
GCC 4.4.6 April 16, 2011  
GCC 4.6.0 March 25, 2011  
GCC 4.5.2 December 16, 2010  
GCC 4.4.5 October 1, 2010  
GCC 4.5.1 July 31, 2010  
GCC 4.3.5 May 22, 2010  
GCC 4.4.4 April 29, 2010  
GCC 4.5.0 April 14, 2010  
GCC 4.4.3 January 21, 2010  
GCC 4.4.2 October 15, 2009  
GCC 4.3.4 August 4, 2009  
GCC 4.4.1 July 22, 2009  
GCC 4.4.0 April 21, 2009  
GCC 4.3.3 January 24, 2009  
GCC 4.3.2 August 27, 2008  
GCC 4.3.1 June 6, 2008  
GCC 4.2.4 May 19, 2008  
GCC 4.3.0 March 5, 2008  
GCC 4.2.3 February 1, 2008  
GCC 4.2.2 October 7, 2007  
GCC 4.2.1 July 18, 2007  
GCC 4.2.0 May 13, 2007  
GCC 4.1.2 February 13, 2007  
GCC 4.0.4 January 31, 2007  
GCC 4.1.1 May 24, 2006  
GCC 4.0.3 March 10, 2006  
GCC 3.4.6 March 06, 2006  
GCC 4.1.0 February 28, 2006  
GCC 3.4.5 November 30, 2005  
GCC 4.0.2 September 28, 2005  
GCC 4.0.1 July 7, 2005  
GCC 3.4.4 May 18, 2005  
GCC 3.3.6 May 3, 2005  
GCC 4.0.0 April 20, 2005  
GCC 3.4.3 November 4, 2004  
GCC 3.3.5 September 30, 2004  
GCC 3.4.2 September 6, 2004  
GCC 3.4.1 July 1, 2004  
GCC 3.3.4 May 31, 2004  
GCC 3.4.0 April 18, 2004  
GCC 3.3.3 February 14, 2004  
GCC 3.3.2 October 17, 2003  
GCC 3.3.1 August 8, 2003  
GCC 3.3 May 13, 2003  
GCC 3.2.3 April 22, 2003  
GCC 3.2.2 February 05, 2003  
GCC 3.2.1 November 19, 2002  
GCC 3.2 August 14, 2002  
GCC 3.1.1 July 25, 2002  
GCC 3.1 May 15, 2002  
GCC 3.0.4 February 20, 2002  
GCC 3.0.3 December 20, 2001  
GCC 3.0.2 October 25, 2001  
GCC 3.0.1 August 20, 2001  
GCC 3.0 June 18, 2001  
GCC 2.95.3 March 16, 2001  
GCC 2.95.2 October 24, 1999  
GCC 2.95.1 August 19, 1999  
GCC 2.95 July 31, 1999  
EGCS 1.1.2 March 15, 1999  
EGCS 1.1.1 December 1, 1998  
EGCS 1.1 September 3, 1998  
EGCS 1.0.3 May 15, 1998  
EGCS 1.0.2 March 16, 1998  
gcc 2.8.1 March 2, 1998  
gcc 2.8.0 January 7, 1998  
EGCS 1.0.1 January 6, 1998  
EGCS 1.0 December 3, 1997  
2.7.2.3 August 22, 1997  
2.7.2.2 January 29, 1997  
2.7.2.1 June 29, 1996  
2.7.2 November 26, 1995  
2.7.1 November 12, 1995  
2.7.0 June 16, 1995  
2.6.3 November 30, 1994  
2.6.2 November 12, 1994  
2.6.1 November 1, 1994  
2.6.0 July 14, 1994  
2.5.8 January 24, 1994  
2.5.7 December 12, 1993  
2.5.6 December 3, 1993  
2.5.5 November 27, 1993  
2.5.4 November 16, 1993  
2.5.3 November 11, 1993  
2.5.2 November 1, 1993  
2.5.1 October 31, 1993  
2.5.0 October 22, 1993  
2.4.5 June 20, 1993  
2.4.4 June 19, 1993  
2.4.3 June 1, 1993  
2.4.2 May 31, 1993  
2.4.1 May 26, 1993  
2.4.0 May 17, 1993  
2.3.3 December 26, 1992  
2.3.2 November 27, 1992  
2.3.1 November 1, 1992  
2.3 October 31, 1992  
2.2.2 June 14, 1992  
2.2.1 June 9, 1992  
2.2 June 8, 1992  
2.1 March 24, 1992  
2.0 February 22, 1992  
1.42.0 (g++) September 20, 1992  
1.42 September 20, 1992  
1.41 August 27, 1992  
1.41.0 (g++) July 13, 1992  
1.40.3 (g++) October 19, 1991  
1.40 June 1, 1991  
1.39.1 (g++) May 4, 1991  
1.39 January 16, 1991  
1.38 December 21, 1990  
1.37.1 (g++) March 1, 1990  
1.37.0 (g++) February 28, 1990  
1.37.1 February 21, 1990  
1.37 February 11, 1990  
1.36.4 (g++) January 30, 1990  
1.36.3 (g++) January 16, 1990  
1.36 September 24, 1989  
1.35 April 26, 1989  
1.34 February 23, 1989  
1.33 February 1, 1989  
1.32 December 21, 1988  
1.31 November 19, 1988  
1.30 October 13, 1988  
1.29 October 6, 1988  
1.28 September 14, 1988  
1.27 September 5, 1988  
1.26 August 18, 1988  
1.25 August 3, 1988  
1.24 July 2, 1988  
1.23 June 26, 1988  
1.22 May 22, 1988  
1.21 May 1, 1988  
1.20 April 19, 1988  
1.19 March 29, 1988  
1.18 February 4, 1988  
1.17 January 9, 1988  
1.16 December 19, 1987  
1.15.3 (g++) December 18, 1987  
1.15 November 28, 1987  
1.14 November 6, 1987  
1.13 October 12, 1987  
1.12 October 3, 1987  
1.11 September 5, 1987 (announced late)  
1.10 August 22, 1987  
1.9 August 18, 1987 (never announced)  
1.8 August 10, 1987  
1.7 July 21, 1987  
1.6 July 2, 1987  
1.5 June 18, 1987  
1.4 June 13, 1987  
1.3 June 10, 1987  
1.2 June 1, 1987  
1.1 May 24, 1987  
1.0 May 23, 1987  
0.9 (first beta release) March 22, 1987  

 

不同GCC版本支持的C语言编译标准
GCC 版本C语言常用标准(WG14委员会维护)
C89/C90C99C11C17GNU90GNU99GNU11GNU17
10.1 ~ 8.4 c89 / c90 c99 c11 c17/c18 gnu90/gnu89 gnu99 gnu11 gnu17/gnu18
7.5 ~ 5.5 c89/c90 c99 c11   gnu90/gnu89 gnu99 gnu11  
4.9.4 ~ 4.8.5 c89/c90 c99 c11   gnu90/gnu89 gnu99 gnu11  
4.7.4 c89/c90 c99(部分支持) c11(部分支持)   gnu90/gnu89 gnu99(部分支持) gnu11(部分支持)  
4.6.4 c89/c90 c99(部分支持) c1x(部分支持)   gnu90/gnu89 gnu99(部分支持) gnu1x(部分支持)  
4.5.4 c89/c90  c99(部分支持)     gnu90/gnu89 gnu99(部分支持)    
  C++ Standards Support in GCC(c++以往的标准支持情况都有详细的阐述)
https://gcc.gnu.org/projects/cxx-status.html#cxx14

 

  进入某个版本文档

一、https://gcc.gnu.org/releases.html

二、https://gcc.gnu.org/gcc-7/
     
      选择一个版本
  


     进入pdf文档
  
 

 

 

 三、文档解释 
 
先看下本机的版本(mingw32使用的是gcc编译器)

C:\Program Files\Go\src\democgo\pointerfunc\dll>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=E:/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/7.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-7.3.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w
64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw730/x86_64-730-posix-sjlj-rt_v5-rev0/mingw64 --enable-shared --enabl
e-static --enable-targets=all --enable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enabl
e-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fu
lly-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --enable-sjlj-exceptions
--disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-
nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch-32=i686 --with-arch-64=nocona --with-tune
-32=generic --with-tune-64=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw730/prerequisites/x86_64-w64-ming
w32-static --with-mpfr=/c/mingw730/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw730/prerequisites/x86_64-w
64-mingw32-static --with-isl=/c/mingw730/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-sjlj-re
v0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I
/c/mingw730/x86_64-730-posix-sjlj-rt_v5-rev0/mingw64/opt/include -I/c/mingw730/prerequisites/x86_64-zlib-static/include
-I/c/mingw730/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw730/x86_64-730-p
osix-sjlj-rt_v5-rev0/mingw64/opt/include -I/c/mingw730/prerequisites/x86_64-zlib-static/include -I/c/mingw730/prerequisi
tes/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw730/x86_64-730-posix-sjlj-rt_v5-rev0/mingw64/opt/include -I/
c/mingw730/prerequisites/x86_64-zlib-static/include -I/c/mingw730/prerequisites/x86_64-w64-mingw32-static/include' LDFLA
GS='-pipe -fno-ident -L/c/mingw730/x86_64-730-posix-sjlj-rt_v5-rev0/mingw64/opt/lib -L/c/mingw730/prerequisites/x86_64-z
lib-static/lib -L/c/mingw730/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 7.3.0 (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project)

  
文档来自:  https://gcc.gnu.org/onlinedocs/gcc-7.5.0/gcc.pdf   

一、Using the GNU Compiler Collection For gcc version 7.5.0 (简介本手册介绍了如何使用GNU编译器7.5.0版本)

Introduction This manual documents how to use the GNU compilers, as well as their features and incompatibilities, and how to report bugs. It corresponds to the compilers (GCC) version 7.5.0. The internals of the GNU compilers, including how to port them to new targets and some information about how to write front ends for new languages, are documented in a separate manual. See Section “Introduction” in GNU Compiler Collection (GCC) Internals.

简介本手册介绍了如何使用GNU编译器,以及它们的特性和不兼容性,以及如何报告错误。它对应于编译器(GCC)7.5.0版。
GNU编译器的内部内容,包括如何将它们移植到新的目标,以及有关如何为新语言编写前端的一些信息,都记录在单独的手册中。
请参阅GNU编译器集合(GCC)内部的“简介”部分。

1 Programming Languages Supported by GCC

    GCC stands for “GNU Compiler Collection”. GCC is an integrated distribution of compilers for several major programming languages. These languages currently include C, C++, Objective-C, Objective-C++, Fortran, Ada, Go, and BRIG (HSAIL).

     The abbreviation GCC has multiple meanings in common use.

    The current official meaning is “GNU Compiler Collection”, which refers generically to the complete suite of tools. The name historically stood for “GNU C Compiler”, and this usage is still common when the emphasis is on compiling C programs. Finally, the name is also used when speaking of the language-independent component of GCC: code shared among the compilers for all supported languages. The language-independent component of GCC includes the majority of the optimizers, as well as the “back ends” that generate machine code for various processors. The part of a compiler that is specific to a particular language is called the “front end”. In addition to the front ends that are integrated components of GCC, there are several other front ends that are maintained separately. These support languages such as Pascal, Mercury, and COBOL. To use these, they must be built together with GCC proper. Most of the compilers for languages other than C have their own names. The C++ compiler is G++, the Ada compiler is GNAT, and so on. When we talk about compiling one of those languages, we might refer to that compiler by its own name, or as GCC. Either is correct. Historically, compilers for many languages, including C++ and Fortran, have been implemented as “preprocessors” which emit another high level language such as C. None of the compilers included in GCC are implemented this way; they all generate machine code directly. This sort of preprocessor should not be confused with the C preprocessor, which is an integral feature of the C, C++, Objective-C and Objective-C++ languages.

   GCC代表“GNU编译器集合”。GCC是几种主要编程语言的编译器的集成发行版。这些语言目前包括C、C++、Objective-C、Objective-C++、Fortran、Ada、Go和BRIG(HSAIL)。缩写GCC有多种常用含义。当前的官方含义是“GNU编译器集合”,它泛指完整的工具套件。该名称在历史上代表“GNU C编译器”,当重点放在编译C程序时,这种用法仍然很常见。最后,当谈到GCC的独立于语言的组件时,也会用到这个名称:所有受支持语言的编译器之间共享的代码。GCC的语言独立组件包括大多数优化器,以及为各种处理器生成机器代码的“后端”。编译器中特定于特定语言的部分称为“前端”。除了作为GCC集成组件的前端之外,还有几个其他前端需要单独维护。这些支持Pascal、Mercury和COBOL等语言。要使用这些,它们必须与GCC一起构建。大多数非C语言的编译器都有自己的名称。C++编译器是G++,Ada编译器是GNAT,等等。当我们谈到编译这些语言中的一种时,我们可能会用它自己的名称来引用该编译器,或者称为GCC。两者都是正确的。历史上,许多语言(包括C++和Fortran)的编译器都是作为“预处理器”实现的,它们发出另一种高级语言(如C)。GCC中的编译器都不是这样实现的;它们都直接生成机器代码。这种预处理器不应与C预处理器混淆,C预处理器是C、C++、Objective-C和Objective-C++语言的一个完整特性。

 

2 Language Standards Supported by GCC For each language compiled by GCC for which there is a standard, GCC attempts to follow one or more versions of that standard, possibly with some exceptions, and possibly with some extensions.

2.1 C Language The original ANSI C standard (X3.159-1989) was ratified in 1989 and published in 1990. This standard was ratified as an ISO standard (ISO/IEC 9899:1990) later in 1990. There were no technical differences between these publications, although the sections of the ANSI standard were renumbered and became clauses in the ISO standard. The ANSI standard, but not the ISO standard, also came with a Rationale document. This standard, in both its forms, is commonly known as C89, or occasionally as C90, from the dates of ratification. To select this standard in GCC, use one of the options ‘-ansi’, ‘-std=c90’ or ‘-std=iso9899:1990’; to obtain all the diagnostics required by the standard, you should also specify ‘-pedantic’ (or ‘-pedantic-errors’ if you want them to be errors rather than warnings). See Section 3.4 [Options Controlling C Dialect], page 33.

GCC支持的语言标准对于GCC编译的每种有标准的语言,GCC尝试遵循该标准的一个或多个版本,可能有一些例外,也可能有一些扩展。

2.1 C语言最初的ANSI C标准(X3.159-1989)于1989年批准,并于1990年发布。本标准于1990年晚些时候被批准为ISO标准(ISO/IEC 9899:1990)。尽管ANSI标准的章节被重新编号并成为ISO标准中的条款,但这些出版物之间没有技术差异。ANSI标准(而非ISO标准)也附带了基本原理文件。自批准之日起,本标准的两种形式通常被称为C89,偶尔也被称为C90。要在GCC中选择此标准,请使用选项之一“-ansi”,“-std=c90”或“-std=iso9899:1990”;要获得标准要求的所有诊断,还应指定“-pedantic”(或“-pedantic errors”(如果希望它们是错误而不是警告)。参见第33页第3.4节[控制C方言的选项]。

 

    Errors in the 1990 ISO C standard were corrected in two Technical Corrigenda published in 1994 and 1996. GCC does not support the uncorrected version.
    An amendment to the 1990 standard was published in 1995. This amendment added digraphs and __STDC_VERSION__ to the language, but otherwise concerned the library. This amendment is commonly known as AMD1; the amended standard is sometimes known as C94 or C95. To select this standard in GCC, use the option ‘-std=iso9899:199409’ (with, as for other standard versions, ‘-pedantic’ to receive all required diagnostics).
    A new edition of the ISO C standard was published in 1999 as ISO/IEC 9899:1999, and is commonly known as C99. (While in development, drafts of this standard version were referred to as C9X.)
   GCC has substantially complete support for this standard version; see http://gcc.gnu.org/c99status.html for details. To select this standard, use ‘-std=c99’ or ‘-std=iso9899:1999’.

 1994年和1996年出版的两份技术勘误表更正了1990年ISO C标准中的错误。GCC不支持未更正的版本。
 1995年发布了对1990年标准的修订。这项修正案在语言中添加了有向图和__STDC_VERSION__ ,但在其他方面与图书馆有关。该修正案通常称为AMD1;修订后的标准有时称为C94或C95。要在GCC中选择此标准,请使用选项“-std=iso9899:199409”(与其他标准版本一样,使用“-pedantic”接收所有所需的诊断)。
 ISO C标准的新版于1999年发布为ISO/IEC 9899:1999,通常称为C99。

(在开发过程中,此标准版本的草案被称为C9X。)
 GCC基本上完全支持该标准版本;看见 http://gcc.gnu.org/c99status.html 有关详细信息。要选择此标准,请使用“-std=c99”或“-std=iso9899:1999”。

 

注: 支持的C语言标准可以使用-std 进行选择,常用的(非全部)选项如下:

-std=c11 Conform to the ISO 2011 C standard
-std=c89 Conform to the ISO 1990 C standard
-std=c90 Conform to the ISO 1990 C standard
-std=c99 Conform to the ISO 1999 C standard

-std=gnu11 Conform to the ISO 2011 C standard with GNU extensions
-std=gnu89 Conform to the ISO 1990 C standard with GNU extensions
-std=gnu90 Conform to the ISO 1990 C standard with GNU extensions
-std=gnu99 Conform to the ISO 1999 C standard with GNU extensions

默认情况下如果不指明-std选项,GCC会使用-std=gnu11作为默认支持的C语言版本,也就是C11标准加上GCC extension的组合。

C标准从C95开始引入了一个宏 __STDC_VERSION__ 来表示当前支持的ISO C语言标准版本

 

   Errors in the 1999 ISO C standard were corrected in three Technical Corrigenda published in 2001, 2004 and 2007. GCC does not support the uncorrected version.

2001年、2004年和2007年出版的三份技术勘误表更正了1999年ISO C标准中的错误。GCC不支持未更正的版本。

 

   A fourth version of the C standard, known as C11, was published in 2011 as ISO/IEC 9899:2011. (While in development, drafts of this standard version were referred to as C1X.) GCC has substantially complete support for this standard, enabled with ‘-std=c11’ or ‘-std=iso9899:2011’.

C标准的第四个版本,即C11,于2011年作为ISO/IEC 9899:2011发布。(在开发过程中,此标准版本的草案被称为C1X。)GCC基本上完全支持该标准,支持“-std=c11”或“-std=iso9899:2011”。

 

   By default, GCC provides some extensions to the C language that, on rare occasions conflict with the C standard. See Chapter 6 [Extensions to the C Language Family], page 405.

 默认情况下,GCC提供了一些对C语言的扩展,这些扩展很少与C标准冲突。参见第6章【C语言家族的扩展】,第405页。

 

   Some features that are part of the C99 standard are accepted as extensions in C90 mode, and some features that are part of the C11 standard are accepted as extensions in C90 and C99 modes. Use of the ‘-std’ options listed above disables these extensions where they conflict with the C standard version selected.

C99标准中的一些功能在C90模式下被接受为扩展,而C11标准中的一些功能在C90和C99模式下被接受为扩展。使用上面列出的“-std”选项将禁用这些与所选C标准版本冲突的扩展。

 

    You may also select an extended version of the C language explicitly with ‘-std=gnu90’ (for C90 with GNU extensions), ‘-std=gnu99’ (for C99 with GNU extensions) or ‘-std=gnu11’ (for C11 with GNU extensions). The default, if no C language dialect options are given, is ‘-std=gnu11’.

您还可以使用“-std=gnu90”(用于带有GNU扩展的C90)、“-std=gnu99”(用于带有GNU扩展的C99)或“-std=gnu11”(用于带有GNU扩展的C11)显式选择C语言的扩展版本。
如果未提供C语言方言选项,则默认值为“-std=gnu11”。

 

   6 Using the GNU Compiler Collection (GCC) The ISO C standard defines (in clause 4) two classes of conforming implementation.

6使用GNU编译器集合(GCC),ISO C标准(在第4条中)定义了两类一致性实现。

 

   A conforming hosted implementation supports the whole standard including all the library facilities;

  一致的托管实现支持整个标准,包括所有图书馆设施;

 

  a conforming freestanding implementation is only required to provide certain library facilities: those in , , , and ; since AMD1, also those in ; since C99, also those in and ;

 and since C11, also those in and . In addition, complex types, added in C99, are not required for freestanding implementations.

只有在提供某些图书馆设施时,才需要符合要求的独立实施:在、和中的图书馆设施;自AMD1起,也包括:;自C99起,也包括和;自C11起,也包括和中的。
此外,C99中添加的复杂类型对于独立实现来说不是必需的。

The standard also defines two environments for programs, a freestanding environment, required of all implementations and which may not have library facilities beyond those required of freestanding implementations, where the handling of program startup and termination are implementation-defined; and a hosted environment, which is not required, in which all the library facilities are provided and startup is through a function int main (void) or int main (int, char *[]). An OS kernel is an example of a program running in a freestanding environment; a program using the facilities of an operating system is an example of a program running in a hosted environment.

该标准还为程序定义了两个环境,一个独立环境,是所有实现所必需的,并且除了独立实现所需的库设施外,可能没有其他库设施,其中程序启动和终止的处理由实现定义;
以及一个托管环境,这是不需要的,其中提供了所有库设施,并且通过函数int main(void)或int main(intchar*[])启动。OS内核是在独立环境中运行的程序的一个示例;
使用操作系统设施的程序是在托管环境中运行的程序的一个示例。

  GCC aims towards being usable as a conforming freestanding implementation, or as the compiler for a conforming hosted implementation.

GCC目标旨在用作一致性独立实现,或用作一致性托管实现的编译器。

  By default, it acts as the compiler for a hosted implementation, defining __STDC_HOSTED__ as 1 and presuming that when the names of ISO C functions are used, they have the semantics defined in the standard. To make it act as a conforming freestanding implementation for a freestanding environment, use the option ‘-ffreestanding’; it then defines __STDC_HOSTED__ to 0 and does not make assumptions about the meanings of function names from the standard library, with exceptions noted below.

  默认情况下,它充当托管实现的编译器,将__STDC_HOSTED__ 定义为1,并假定使用ISO C函数的名称时,它们具有标准中定义的语义。
要使其作为独立环境的一致独立实现,请使用选项“-ffreestanding”;然后,它将__STDC_HOSTED__定义为0,并且不对标准库中函数名的含义进行假设,以下列出了例外情况。

  To build an OS kernel, you may well still need to make your own arrangements for linking and startup. See Section 3.4 [Options Controlling C Dialect], page 33.   

要构建操作系统内核,您可能仍然需要自行安排链接和启动。参见第33页第3.4节[控制C方言的选项]。

   GCC does not provide the library facilities required only of hosted implementations, nor yet all the facilities required by C99 of freestanding implementations on all platforms.

GCC不提供仅托管实现所需的库设施,也不提供C99在所有平台上独立实现所需的所有设施。

   To use the facilities of a hosted environment, you need to find them elsewhere (for example, in the GNU C library). See Section 13.5 [Standard Libraries], page 792. Most of the compiler support routines used by GCC are present in ‘libgcc’, but there are a few exceptions. GCC requires the freestanding environment provide memcpy, memmove, memset and memcmp. Finally, if __builtin_trap is used, and the target does not implement the trap pattern, then GCC emits a call to abort. For references to Technical Corrigenda, Rationale documents and information concerning the history of C that is available online, see http://gcc.gnu.org/readings.html

  要使用托管环境的设施,您需要在其他地方找到它们(例如,在GNU C库中)。参见第792页第13.5节[标准库]。GCC使用的大多数编译器支持例程都存在于“libgcc”中,但也有一些例外。
  GCC要求独立式环境提供memcpy、memmove、memset和memcmp。最后,如果使用了__builtin_trap,并且目标没有实现陷阱模式,那么GCC将发出中止调用。
   有关技术勘误表、基本原理文件和有关C历史的信息,请在线查阅  http://gcc.gnu.org/readings.html
   

  二、选项命令行
  The following options control the dialect of C (or languages derived from C,
           such as C++, Objective-C and Objective-C++) that the compiler accepts:

-ansi  In C mode, this is equivalent to ‘-std=c90’. In C++ mode, it is equivalent to

   ‘-std=c++98’.

   This turns off certain features of GCC that are incompatible with ISO C90

   (when compiling C code), or of standard C++ (when compiling C++ code), such

   as the asm and typeof keywords, and predefined macros such as unix and vax

   that identify the type of system you are using. It also enables the undesirable

  34 Using the GNU Compiler Collection (GCC)

  and rarely used ISO trigraph feature. For the C compiler, it disables recognition

  of C++ style ‘//’ comments as well as the inline keyword.

  The alternate keywords __asm__, __extension__, __inline__ and __typeof_

  _ continue to work despite ‘-ansi’. You would not want to use them in an ISO

  C program, of course, but it is useful to put them in header files that might be

  included in compilations done with ‘-ansi’. Alternate predefined macros such

  as __unix__ and __vax__ are also available, with or without ‘-ansi’.

  The ‘-ansi’ option does not cause non-ISO programs to be rejected

  gratuitously. For that, ‘-Wpedantic’ is required in addition to ‘-ansi’. See

  Section 3.8 [Warning Options], page 59.

  The macro __STRICT_ANSI__ is predefined when the ‘-ansi’ option is used.

  Some header files may notice this macro and refrain from declaring certain

  functions or defining certain macros that the ISO standard doesn’t call for; this

  is to avoid interfering with any programs that might use these names for other

  things.

  Functions that are normally built in but do not have semantics defined by ISO

  C (such as alloca and ffs) are not built-in functions when ‘-ansi’ is used. See

  Section 6.59 [Other built-in functions provided by GCC], page 572, for details of the functions affected.

-std= Determine the language standard. See Chapter 2
        [Language Standards Supported by GCC],
        page 5, for details of these standard versions. This option is

  currently only supported when compiling C or C++.

  The compiler can accept several base standards, such as ‘c90’ or ‘c++98’, and

  GNU dialects of those standards, such as ‘gnu90’ or ‘gnu++98’. When a base

  standard is specified, the compiler accepts all programs following that standard plus those
         using GNU extensions that do not contradict it. For example,

  ‘-std=c90’ turns off certain features of GCC that are incompatible with ISO

  C90, such as the asm and typeof keywords, but not other GNU extensions that

  do not have a meaning in ISO C90, such as omitting the middle term of a ?:

  expression. On the other hand, when a GNU dialect of a standard is specified,

  all features supported by the compiler are enabled, even when those features

  change the meaning of the base standard. As a result, some strict-conforming

  programs may be rejected. The particular standard is used by ‘-Wpedantic’ to

  identify which features are GNU extensions given that version of the standard.

  For example ‘-std=gnu90 -Wpedantic’ warns about C++ style ‘//’ comments,

  while ‘-std=gnu99 -Wpedantic’ does not.

  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.

  Chapter 3: GCC Command Options 35

  ‘c99’

  ‘c9x’

  ‘iso9899:1999’

  ‘iso9899:199x’

  ISO C99. This standard is substantially completely supported,

  modulo bugs and floating-point issues (mainly but not entirely

  relating to optional C99 features from Annexes F and G). See

  http://gcc.gnu.org/c99status.html for more information. The

  names ‘c9x’ and ‘iso9899:199x’ are deprecated.

  ‘c11’

  ‘c1x’

  ‘iso9899:2011’

  ISO C11, the 2011 revision of the ISO C standard. This standard is

  substantially completely supported, modulo bugs, floating-point issues
       (mainly but not entirely relating   to optional C11 features from Annexes F and G)
       and the optional Annexes K (Bounds-checking

  interfaces) and L (Analyzability). The name ‘c1x’ is deprecated.

  ‘gnu90’

  ‘gnu89’ GNU dialect of ISO C90 (including some C99 features).

  ‘gnu99’

  ‘gnu9x’ GNU dialect of ISO C99. The name ‘gnu9x’ is deprecated.

  ‘gnu11’

  ‘gnu1x’ GNU dialect of ISO C11. This is the default for C code. The name

  ‘gnu1x’ is deprecated.

  ‘c++98’

  ‘c++03’ The 1998 ISO C++ standard plus the 2003 technical corrigendum and some additional defect reports.
            Same as ‘-ansi’ for C++ code.

  ‘gnu++98’

  ‘gnu++03’ GNU dialect of ‘-std=c++98’.

  ‘c++11’

  ‘c++0x’ The 2011 ISO C++ standard plus amendments. The name ‘c++0x’ is deprecated.

  ‘gnu++11’

  ‘gnu++0x’ GNU dialect of ‘-std=c++11’. The name ‘gnu++0x’ is deprecated.

  ‘c++14’

  ‘c++1y’ The 2014 ISO C++ standard plus amendments. The name ‘c++1y’ is deprecated.

  ‘gnu++14’

  ‘gnu++1y’ GNU dialect of ‘-std=c++14’. This is the default for C++ code.The name ‘gnu++1y’ is deprecated.

  ‘c++1z’ The next revision of the ISO C++ standard, tentatively planned for 2017.
            Support is highly experimental, and will almost certainly  change in incompatible ways in future releases.

  36 Using the GNU Compiler Collection (GCC)

  ‘gnu++1z’ GNU dialect of ‘-std=c++1z’. Support is highly experimental,
                  and  will almost certainly change in incompatible ways in future releases 

posted @ 2022-06-06 10:35  jinzi  阅读(58)  评论(0编辑  收藏  举报