⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 standards.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>Using the GNU Compiler Collection (GCC)</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="Using the GNU Compiler Collection (GCC)">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

<!--

Copyright &copy; 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,

1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.



   <p>Permission is granted to copy, distribute and/or modify this document

under the terms of the GNU Free Documentation License, Version 1.2 or

any later version published by the Free Software Foundation; with the

Invariant Sections being "GNU General Public License" and "Funding

Free Software", the Front-Cover texts being (a) (see below), and with

the Back-Cover Texts being (b) (see below).  A copy of the license is

included in the section entitled "GNU Free Documentation License".



   <p>(a) The FSF's Front-Cover Text is:



   <p>A GNU Manual



   <p>(b) The FSF's Back-Cover Text is:



   <p>You have freedom to copy and modify this GNU Manual, like GNU

     software.  Copies published by the Free Software Foundation raise

     funds for GNU development.-->

</head>

<body>

<div class="node">

<p>

Node:<a name="Standards">Standards</a>,

Next:<a rel="next" accesskey="n" href="Invoking-GCC.html#Invoking%20GCC">Invoking GCC</a>,

Previous:<a rel="previous" accesskey="p" href="G---and-GCC.html#G++%20and%20GCC">G++ and GCC</a>,

Up:<a rel="up" accesskey="u" href="index.html#Top">Top</a>

<hr><br>

</div>



<h2 class="chapter">Language Standards Supported by GCC</h2>



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



   <p>GCC supports three versions of the C standard, although support for

the most recent version is not yet complete.



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

This standard, in both its forms, is commonly known as <dfn>C89</dfn>, or

occasionally as <dfn>C90</dfn>, from the dates of ratification.  The ANSI

standard, but not the ISO standard, also came with a Rationale

document.  To select this standard in GCC, use one of the options

<code>-ansi</code>, <code>-std=c89</code> or <code>-std=iso9899:1990</code>; to obtain

all the diagnostics required by the standard, you should also specify

<code>-pedantic</code> (or <code>-pedantic-errors</code> if you want them to be

errors rather than warnings).  See <a href="C-Dialect-Options.html#C%20Dialect%20Options">Options Controlling C Dialect</a>.



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



   <p>An amendment to the 1990 standard was published in 1995.  This

amendment added digraphs and <code>__STDC_VERSION__</code> to the language,

but otherwise concerned the library.  This amendment is commonly known

as <dfn>AMD1</dfn>; the amended standard is sometimes known as <dfn>C94</dfn> or

<dfn>C95</dfn>.  To select this standard in GCC, use the option

<code>-std=iso9899:199409</code> (with, as for other standard versions,

<code>-pedantic</code> to receive all required diagnostics).



   <p>A new edition of the ISO C standard was published in 1999 as ISO/IEC

9899:1999, and is commonly known as <dfn>C99</dfn>.  GCC has incomplete

support for this standard version; see

<a href="http://gcc.gnu.org/gcc-3.3/c99status.html">http://gcc.gnu.org/gcc-3.3/c99status.html</a> for details.  To select this

standard, use <code>-std=c99</code> or <code>-std=iso9899:1999</code>.  (While in

development, drafts of this standard version were referred to as

<dfn>C9X</dfn>.)



   <p>Errors in the 1999 ISO C standard were corrected in a Technical

Corrigendum published in 2001.  GCC does not support the uncorrected

version.



   <p>By default, GCC provides some extensions to the C language that on

rare occasions conflict with the C standard.  See <a href="C-Extensions.html#C%20Extensions">Extensions to the C Language Family</a>.  Use of the

<code>-std</code> options listed above will disable these extensions where

they conflict with the C standard version selected.  You may also

select an extended version of the C language explicitly with

<code>-std=gnu89</code> (for C89 with GNU extensions) or <code>-std=gnu99</code>

(for C99 with GNU extensions).  The default, if no C language dialect

options are given, is <code>-std=gnu89</code>; this will change to

<code>-std=gnu99</code> in some future release when the C99 support is

complete.  Some features that are part of the C99 standard are

accepted as extensions in C89 mode.



   <p>The ISO C standard defines (in clause 4) two classes of conforming

implementation.  A <dfn>conforming hosted implementation</dfn> supports the

whole standard including all the library facilities; a <dfn>conforming

freestanding implementation</dfn> is only required to provide certain

library facilities: those in <code>&lt;float.h&gt;</code>, <code>&lt;limits.h&gt;</code>,

<code>&lt;stdarg.h&gt;</code>, and <code>&lt;stddef.h&gt;</code>; since AMD1, also those in

<code>&lt;iso646.h&gt;</code>; and in C99, also those in <code>&lt;stdbool.h&gt;</code> and

<code>&lt;stdint.h&gt;</code>.  In addition, complex types, added in C99, are not

required for freestanding implementations.  The standard also defines

two environments for programs, a <dfn>freestanding environment</dfn>,

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 <dfn>hosted environment</dfn>, which is not

required, in which all the library facilities are provided and startup

is through a function <code>int main (void)</code> or <code>int main (int,

char *[])</code>.  An OS kernel would be a freestanding environment; a

program using the facilities of an operating system would normally be

in a hosted implementation.



   <p>GCC aims towards being usable as a conforming freestanding

implementation, or as the compiler for a conforming hosted

implementation.  By default, it will act as the compiler for a hosted

implementation, defining <code>__STDC_HOSTED__</code> as <code>1</code> 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 <code>-ffreestanding</code>; it will then define

<code>__STDC_HOSTED__</code> to <code>0</code> and not make assumptions about the

meanings of function names from the standard library, with exceptions

noted below.  To build an OS kernel, you may well still need to make

your own arrangements for linking and startup. 

See <a href="C-Dialect-Options.html#C%20Dialect%20Options">Options Controlling C Dialect</a>.



   <p>GCC does not provide the library facilities required only of hosted

implementations, nor yet all the facilities required by C99 of

freestanding implementations; to use the facilities of a hosted

environment, you will need to find them elsewhere (for example, in the

GNU C library).  See <a href="Standard-Libraries.html#Standard%20Libraries">Standard Libraries</a>.



   <p>Most of the compiler support routines used by GCC are present in

<code>libgcc</code>, but there are a few exceptions.  GCC requires the

freestanding environment provide <code>memcpy</code>, <code>memmove</code>,

<code>memset</code> and <code>memcmp</code>.  Some older ports of GCC are

configured to use the BSD <code>bcopy</code>, <code>bzero</code> and <code>bcmp</code>

functions instead, but this is deprecated for new ports. 

Finally, if <code>__builtin_trap</code> is used, and the target does

not implement the <code>trap</code> pattern, then GCC will emit a call

to <code>abort</code>.



   <p>For references to Technical Corrigenda, Rationale documents and

information concerning the history of C that is available online, see

<a href="http://gcc.gnu.org/readings.html">http://gcc.gnu.org/readings.html</a>



   <p>There is no formal written standard for Objective-C.  The most

authoritative manual is "Object-Oriented Programming and the

Objective-C Language", available at a number of web sites



     <ul>

<li><a href="http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/">http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/</a>

is a recent version

<li><a href="http://www.toodarkpark.org/computers/objc/">http://www.toodarkpark.org/computers/objc/</a>

is an older example

<li><a href="http://www.gnustep.org">http://www.gnustep.org</a>

has additional useful information

</ul>



   <p>There is no standard for treelang, which is a sample language front end

for GCC. Its only purpose is as a sample for people wishing to write a

new language for GCC. The language is documented in

<code>gcc/treelang/treelang.texi</code> which can be turned into info or

HTML format.



   <p>See <a href="../gnat_rm/index.html#Top">GNAT Reference Manual</a>, for information on standard

conformance and compatibility of the Ada compiler.



   <p>See <a href="../g77/Language.html#Language">The GNU Fortran Language</a>, for details of the Fortran language supported by GCC.



   <p>See <a href="../gcj/Compatibility.html#Compatibility">Compatibility with the Java Platform</a>,

for details of compatibility between <code>gcj</code> and the Java Platform.



   </body></html>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -