C Language Standards Supported by GCC (GCC 支持的C语言标准)

Using the GNU Compiler Collection

Language Standards Supported by GCC

GCC支持的语言标准

For each language compiled by GCC for which there is a standard,

对于由GCC编译的每种语言都有一个标准

GCC attempts to follow one or more versions of that standard,

GCC尝试遵循该标准的一个或多个版本

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.

原 ANSI C 标准(X3.159-1989)于1989年获得批准,并在1990年出版。

This standard was ratified as an ISO standard (ISO/IEC 9899:1990) later in 1990.

1990年的晚些时候被批准为ISO标准(ISO/IEC 9899: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.

这些出版物之间没有技术差异,尽管ANSI的部分标准被重新编号成为 ISO 标准条款。

The ANSI standard, but not the ISO standard, also came with a Rationale document.

但是 ANSI 标准相比于 ISO 标准,还附有一个基本原理的文档。

This standard, in both its forms, is commonly known as C89, or occasionally as C90, from the dates of ratifcation.

这个标准自批准之日起以两种形式存在,通常被称为C89,有时也称为C90

To select this standard in GCC, use one of the options‘-ansi’,‘-std=c90’or‘-std=iso9899:1990’;

要在GCC中选择此标准,可使用选项 '-ansi''-std=c90''-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.

为了获得该标准所需要的所有诊断信息,
您还应该指定'-pedantic'( 或'-pedantic-errors',如果您希望它们是错误而不是警告 )。
详见3.4节 [ 控制C语言选项 ], 33页

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.

在 1994年 和 1996年, 1990年 ISO C 标准的错误已在两份发布的技术勘误表中得到纠正.
GCC不支持未校正的版本。

An amendment to the 1990 standard was published in 1995.

1995年出版了1990年标准的修正案。

This amendment added digraphs and __STDC_VERSION__ to the language, but otherwise concerned the library.

这个修正案添加了 digraphs 和 __STDC_VERSION__ 到 C 语言中,但是并没有涉及这个库的其他方面

This amendment is commonly known as AMD1; the amended standard is sometimes known as C94 or C95.

这个修正案俗称为 AMD1; 修订后的标准被称为 C94C95

To select this standard in GCC, use the option‘-std=iso9899:199409’(with, as for other standard versions,‘-pedantic’to receive all required diagnostics).

要在GCC中选择此标准,请使用选项'-std=iso9899:199409'(与其他标准版本一样, '-pedantic' 接收所需要的诊断信息)

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

1999年 ISO C standard 的新版本作为 ISO/IEC 9899:1999 出版,通常被称为 C99
(在开发时,本标准版的草案被称为 C9X)

GCC has substantially complete support for this standard version; see http://gcc.gnu.org/c99status.html for details.

GCC 对此标准的版本基本完全支持; 详见 http://gcc.gnu.org/c99status.html

To select this standard, use‘-std=c99’or‘-std=iso9899:1999’.

要选择此标准,请使用'-std=c99''-std=iso9899:1999'

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

2011年 C标准的第四版,被称为 C11,作为ISO/IEC 9899:2011出版。
在开发过程中,本标准版的草案被称为 C1X

GCC has substantially complete support for this standard, enabled with‘-std=c11’or‘-std=iso9899:2011’.

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

默认情况下,GCC为C语言提供了一些扩展,在极少的情况下,与C标准相冲突。
详见第6章 [ 扩展C语言家族 ], 403页

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.

C99标准的部分特性被扩展到了 C90 模式,C11 标准的部分特性被扩展到了 C90 和 C99 模式

Use of the‘-std’options listed above disables these extensions where they conflict with the C standard version selected.

使用上面列出的 '-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).

您还可以使用
'-std=gnu90' ( 对应 C90 GNU扩展 ),
'-std=gnu99' ( 对应 C99 GNU扩展 ) 或
'-std=gnu11' ( 对应 C11 GNU扩展 ) 这些选项可以明确地指定 C 语言的扩展版本

The default, if no C language dialect options are given, is‘-std=gnu11’.

默认情况下,如果没有给出C语言方言选项,默认为'std = gnu11'


The ISO C standard defnes (in clause 4) two classes of conforming implementation.

ISO C 标准( 在第四节 ) 规定了两个符合标准的实现方式

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

一个是符合标准的托管实现方式(hosted implementation) 能够支持严格遵循标准的全部库文件(library facilities)

a conforming freestanding implementation is only required to provide certain library facilities :
those in <float.h>, <limits.h>, <stdarg.h>, and <stddef.h>;
since AMD1, also those in <iso646.h>;
since C99, also those in <stdbool.h> and <stdint.h>;
and since C11, also those in <stdalign.h> and <stdnoreturn.h>.
In addition, complex types, added in C99, are not required for freestanding implementations.

而另一个是符合标准的独立实现方式(freestanding implementation) 仅支持某几个库文件 :
这些库文件有 <float.h>, <limits.h>, <stdarg.h>, 和<stddef.h>;
到 AMD1 修正案时,还有 <iso646.h>
到 C99 时, 还有<stdbool.h><stdint.h>;
再到 C11 时, 还有<stdalign.h><stdnoreturn.h>.
此外,在C99 中添加的 complex 类型,在独立实现方式(freestanding implementation)中是不需要的

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;

该标准还为程序定义了两个环境,一个是 独立环境(freestanding environment)
要求所有的实现 除了那些独立实现(freestanding implementation)所需的库之外不依赖其他库设施
而且要在指定的地方实现已定义的程序的启动和停止

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 *[]).

而对于托管环境(hosted environment)则是通过一个函数int main (void)int main (int, char *[])来启动并且提供了所有的库设施

An OS kernel is an example of a program running in a freestanding environment;

系统内核就是一个在独立环境(freestanding environment)中运行的程序示例;

a program using the facilities of an operating system is an example of a program running in a hosted environment.

而使用操作系统设施的程序就是一个在托管环境(hosted environment)中运行的程序示例。

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

GCC 的目标是成为符合标准的独立实现 (freestanding implementation)程序,或者作为托管实现(hosted implementation)程序的编译器

By default, it acts as the compiler for a hosted implementation, defning __STDC_HOSTED__ as 1
and presuming that when the names of ISO C functions are used, they have the semantics defned in the standard.

默认情况下,GCC作为托管实现方式(hosted implementation)程序的编译器,
__STDC_HOSTED__定义为1,并且当使用 ISO C 的函数名时,假定它们在标准中定义了语义

To make it act as a conforming freestanding implementation for a freestanding environment,
use the option‘-ffreestanding’;

为使 GCC 作为独立环境(freestanding environment)下的独立实现(freestanding implementation), 可以使用'-ffreestanding' 选项

it then defnes __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__定义为 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.

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

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本身并不提供托管实现(hosted implementations) 所需的库设施,
也不提供C99在所有平台上独立实现(freestanding implementation)所需的所有设施。

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

要使用托管环境的设施,您需要在其他地方找到它们 (比如, GNU 的 C 库)
详见 13.5 节 [ 标准库 ],788页

Most of the compiler support routines used by GCC are present in‘libgcc’, but there are a few exceptions.

GCC使用的大多数编译器支持例程都存在于'libgcc'中,但也有一些例外。

GCC requires the freestanding environment provide memcpy, memmove, memset and memcmp.

GCC需要独立环境(freestanding environment)中提供 memcpy,memmove,memset 和 memcmp

Finally, if __builtin_trap is used, and the target does not implement the trap pattern, then GCC emits a call to abort.

最后,如果使用__builtin_trap,并且目标没有实现陷阱模式(trap pattern),那么GCC将发出一个中止调用。

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

参考文献,在线可用的C历史的阐述文档和信息,
详见 http://gcc.gnu.org/readings.html

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