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

📄 standards.html

📁 自己收集的linux入门到学懂高级编程书集 包括linux程序设计第三版
💻 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.6"><!--Copyright &copy; 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.   <p>Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with theInvariant Sections being "GNU General Public License" and "FundingFree Software", the Front-Cover texts being (a) (see below), and withthe Back-Cover Texts being (b) (see below).  A copy of the license isincluded 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.--><meta http-equiv="Content-Style-Type" content="text/css"><style type="text/css"><!--  pre.display { font-family:inherit }  pre.format  { font-family:inherit }  pre.smalldisplay { font-family:inherit; font-size:smaller }  pre.smallformat  { font-family:inherit; font-size:smaller }  pre.smallexample { font-size:smaller }  pre.smalllisp    { font-size:smaller }--></style></head><body><div class="node"><p>Node:&nbsp;<a name="Standards">Standards</a>,Next:&nbsp;<a rel="next" accesskey="n" href="Invoking-GCC.html#Invoking%20GCC">Invoking GCC</a>,Previous:&nbsp;<a rel="previous" accesskey="p" href="G---and-GCC.html#G++%20and%20GCC">G++ and GCC</a>,Up:&nbsp;<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, GCCattempts to follow one or more versions of that standard, possiblywith some exceptions, and possibly with some extensions.   <p>GCC supports three versions of the C standard, although support forthe most recent version is not yet complete.   <p>The original ANSI C standard (X3.159-1989) was ratified in 1989 andpublished in 1990.  This standard was ratified as an ISO standard(ISO/IEC 9899:1990) later in 1990.  There were no technicaldifferences between these publications, although the sections of theANSI standard were renumbered and became clauses in the ISO standard. This standard, in both its forms, is commonly known as <dfn>C89</dfn>, oroccasionally as <dfn>C90</dfn>, from the dates of ratification.  The ANSIstandard, but not the ISO standard, also came with a Rationaledocument.  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 obtainall the diagnostics required by the standard, you should also specify<code>-pedantic</code> (or <code>-pedantic-errors</code> if you want them to beerrors 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 TechnicalCorrigenda published in 1994 and 1996.  GCC does not support theuncorrected version.   <p>An amendment to the 1990 standard was published in 1995.  Thisamendment added digraphs and <code>__STDC_VERSION__</code> to the language,but otherwise concerned the library.  This amendment is commonly knownas <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/IEC9899:1999, and is commonly known as <dfn>C99</dfn>.  GCC has incompletesupport for this standard version; see<a href="http://gcc.gnu.org/c99status.html">http://gcc.gnu.org/c99status.html</a> for details.  To select thisstandard, use <code>-std=c99</code> or <code>-std=iso9899:1999</code>.  (While indevelopment, drafts of this standard version were referred to as<dfn>C9X</dfn>.)   <p>Errors in the 1999 ISO C standard were corrected in a TechnicalCorrigendum published in 2001.  GCC does not support the uncorrectedversion.   <p>By default, GCC provides some extensions to the C language that onrare 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 wherethey conflict with the C standard version selected.  You may alsoselect 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 dialectoptions are given, is <code>-std=gnu89</code>; this will change to<code>-std=gnu99</code> in some future release when the C99 support iscomplete.  Some features that are part of the C99 standard areaccepted as extensions in C89 mode.   <p>The ISO C standard defines (in clause 4) two classes of conformingimplementation.  A <dfn>conforming hosted implementation</dfn> supports thewhole standard including all the library facilities; a <dfn>conformingfreestanding implementation</dfn> is only required to provide certainlibrary 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 notrequired for freestanding implementations.  The standard also definestwo environments for programs, a <dfn>freestanding environment</dfn>,required of all implementations and which may not have libraryfacilities beyond those required of freestanding implementations,where the handling of program startup and termination areimplementation-defined, and a <dfn>hosted environment</dfn>, which is notrequired, in which all the library facilities are provided and startupis through a function <code>int main (void)</code> or <code>int main (int,char *[])</code>.  An OS kernel would be a freestanding environment; aprogram using the facilities of an operating system would normally bein a hosted implementation.   <p>GCC aims towards being usable as a conforming freestandingimplementation, or as the compiler for a conforming hostedimplementation.  By default, it will act as the compiler for a hostedimplementation, defining <code>__STDC_HOSTED__</code> as <code>1</code> andpresuming that when the names of ISO C functions are used, they havethe semantics defined in the standard.  To make it act as a conformingfreestanding implementation for a freestanding environment, use theoption <code>-ffreestanding</code>; it will then define<code>__STDC_HOSTED__</code> to <code>0</code> and not make assumptions about themeanings of function names from the standard library, with exceptionsnoted below.  To build an OS kernel, you may well still need to makeyour 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 hostedimplementations, nor yet all the facilities required by C99 offreestanding implementations; to use the facilities of a hostedenvironment, you will need to find them elsewhere (for example, in theGNU 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 thefreestanding environment provide <code>memcpy</code>, <code>memmove</code>,<code>memset</code> and <code>memcmp</code>.  Some older ports of GCC areconfigured 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 doesnot implement the <code>trap</code> pattern, then GCC will emit a callto <code>abort</code>.   <p>For references to Technical Corrigenda, Rationale documents andinformation 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 mostauthoritative manual is "Object-Oriented Programming and theObjective-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 endfor GCC. Its only purpose is as a sample for people wishing to write anew language for GCC. The language is documented in<code>gcc/treelang/treelang.texi</code> which can be turned into info orHTML format.   <p>See <a href="../gnat_rm/index.html#Top">GNAT Reference Manual</a>, for information on standardconformance 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 + -