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

📄 overall-options.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="Overall%20Options">Overall Options</a>,

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

Previous:<a rel="previous" accesskey="p" href="Option-Summary.html#Option%20Summary">Option Summary</a>,

Up:<a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking%20GCC">Invoking GCC</a>

<hr><br>

</div>



<h3 class="section">Options Controlling the Kind of Output</h3>



   <p>Compilation can involve up to four stages: preprocessing, compilation

proper, assembly and linking, always in that order.  The first three

stages apply to an individual source file, and end by producing an

object file; linking combines all the object files (those newly

compiled, and those specified as input) into an executable file.



   <p>For any given input file, the file name suffix determines what kind of

compilation is done:



     <dl>

<dt><code></code><var>file</var><code>.c</code>

     <dd>C source code which must be preprocessed.



     <br><dt><code></code><var>file</var><code>.i</code>

     <dd>C source code which should not be preprocessed.



     <br><dt><code></code><var>file</var><code>.ii</code>

     <dd>C++ source code which should not be preprocessed.



     <br><dt><code></code><var>file</var><code>.m</code>

     <dd>Objective-C source code.  Note that you must link with the library

<code>libobjc.a</code> to make an Objective-C program work.



     <br><dt><code></code><var>file</var><code>.mi</code>

     <dd>Objective-C source code which should not be preprocessed.



     <br><dt><code></code><var>file</var><code>.h</code>

     <dd>C header file (not to be compiled or linked).



     <br><dt><code></code><var>file</var><code>.cc</code>

     <dd><dt><code></code><var>file</var><code>.cp</code>

     <dd><dt><code></code><var>file</var><code>.cxx</code>

     <dd><dt><code></code><var>file</var><code>.cpp</code>

     <dd><dt><code></code><var>file</var><code>.c++</code>

     <dd><dt><code></code><var>file</var><code>.C</code>

     <dd>C++ source code which must be preprocessed.  Note that in <code>.cxx</code>,

the last two letters must both be literally <code>x</code>.  Likewise,

<code>.C</code> refers to a literal capital C.



     <br><dt><code></code><var>file</var><code>.f</code>

     <dd><dt><code></code><var>file</var><code>.for</code>

     <dd><dt><code></code><var>file</var><code>.FOR</code>

     <dd>Fortran source code which should not be preprocessed.



     <br><dt><code></code><var>file</var><code>.F</code>

     <dd><dt><code></code><var>file</var><code>.fpp</code>

     <dd><dt><code></code><var>file</var><code>.FPP</code>

     <dd>Fortran source code which must be preprocessed (with the traditional

preprocessor).



     <br><dt><code></code><var>file</var><code>.r</code>

     <dd>Fortran source code which must be preprocessed with a RATFOR

preprocessor (not included with GCC).



     <p>See <a href="../g77/Overall-Options.html#Overall%20Options">Options Controlling the Kind of Output</a>, for more details of the handling of

Fortran input files.



     <br><dt><code></code><var>file</var><code>.ads</code>

     <dd>Ada source code file which contains a library unit declaration (a

declaration of a package, subprogram, or generic, or a generic

instantiation), or a library unit renaming declaration (a package,

generic, or subprogram renaming declaration).  Such files are also

called <dfn>specs</dfn>.



     <dt><code></code><var>file</var><code>.adb</code>

     <dd>Ada source code file containing a library unit body (a subprogram or

package body).  Such files are also called <dfn>bodies</dfn>.



     <br><dt><code></code><var>file</var><code>.s</code>

     <dd>Assembler code.



     <br><dt><code></code><var>file</var><code>.S</code>

     <dd>Assembler code which must be preprocessed.



     <br><dt><code></code><var>other</var><code></code>

     <dd>An object file to be fed straight into linking. 

Any file name with no recognized suffix is treated this way. 

</dl>



   <p>You can specify the input language explicitly with the <code>-x</code> option:



     <dl>

<dt><code>-x </code><var>language</var><code></code>

     <dd>Specify explicitly the <var>language</var> for the following input files

(rather than letting the compiler choose a default based on the file

name suffix).  This option applies to all following input files until

the next <code>-x</code> option.  Possible values for <var>language</var> are:

     <pre class="example">          c  c-header  cpp-output

          c++  c++-cpp-output

          objective-c  objc-cpp-output

          assembler  assembler-with-cpp

          ada

          f77  f77-cpp-input  ratfor

          java

          treelang

          </pre>



     <br><dt><code>-x none</code>

     <dd>Turn off any specification of a language, so that subsequent files are

handled according to their file name suffixes (as they are if <code>-x</code>

has not been used at all).



     <br><dt><code>-pass-exit-codes</code>

     <dd>Normally the <code>gcc</code> program will exit with the code of 1 if any

phase of the compiler returns a non-success return code.  If you specify

<code>-pass-exit-codes</code>, the <code>gcc</code> program will instead return with

numerically highest error produced by any phase that returned an error

indication. 

</dl>



   <p>If you only want some of the stages of compilation, you can use

<code>-x</code> (or filename suffixes) to tell <code>gcc</code> where to start, and

one of the options <code>-c</code>, <code>-S</code>, or <code>-E</code> to say where

<code>gcc</code> is to stop.  Note that some combinations (for example,

<code>-x cpp-output -E</code>) instruct <code>gcc</code> to do nothing at all.



     <dl>

<dt><code>-c</code>

     <dd>Compile or assemble the source files, but do not link.  The linking

stage simply is not done.  The ultimate output is in the form of an

object file for each source file.



     <p>By default, the object file name for a source file is made by replacing

the suffix <code>.c</code>, <code>.i</code>, <code>.s</code>, etc., with <code>.o</code>.



     <p>Unrecognized input files, not requiring compilation or assembly, are

ignored.



     <br><dt><code>-S</code>

     <dd>Stop after the stage of compilation proper; do not assemble.  The output

is in the form of an assembler code file for each non-assembler input

file specified.



     <p>By default, the assembler file name for a source file is made by

replacing the suffix <code>.c</code>, <code>.i</code>, etc., with <code>.s</code>.



     <p>Input files that don't require compilation are ignored.



     <br><dt><code>-E</code>

     <dd>Stop after the preprocessing stage; do not run the compiler proper.  The

output is in the form of preprocessed source code, which is sent to the

standard output.



     <p>Input files which don't require preprocessing are ignored.



     <br><dt><code>-o </code><var>file</var><code></code>

     <dd>Place output in file <var>file</var>.  This applies regardless to whatever

sort of output is being produced, whether it be an executable file,

an object file, an assembler file or preprocessed C code.



     <p>Since only one output file can be specified, it does not make sense to

use <code>-o</code> when compiling more than one input file, unless you are

producing an executable file as output.



     <p>If <code>-o</code> is not specified, the default is to put an executable file

in <code>a.out</code>, the object file for <code></code><var>source</var><code>.</code><var>suffix</var><code></code> in

<code></code><var>source</var><code>.o</code>, its assembler file in <code></code><var>source</var><code>.s</code>, and

all preprocessed C source on standard output.



     <br><dt><code>-v</code>

     <dd>Print (on standard error output) the commands executed to run the stages

of compilation.  Also print the version number of the compiler driver

program and of the preprocessor and the compiler proper.



     <br><dt><code>-###</code>

     <dd>Like <code>-v</code> except the commands are not executed and all command

arguments are quoted.  This is useful for shell scripts to capture the

driver-generated command lines.



     <br><dt><code>-pipe</code>

     <dd>Use pipes rather than temporary files for communication between the

various stages of compilation.  This fails to work on some systems where

the assembler is unable to read from a pipe; but the GNU assembler has

no trouble.



     <br><dt><code>--help</code>

     <dd>Print (on the standard output) a description of the command line options

understood by <code>gcc</code>.  If the <code>-v</code> option is also specified

then <code>--help</code> will also be passed on to the various processes

invoked by <code>gcc</code>, so that they can display the command line options

they accept.  If the <code>-W</code> option is also specified then command

line options which have no documentation associated with them will also

be displayed.



     <br><dt><code>--target-help</code>

     <dd>Print (on the standard output) a description of target specific command

line options for each tool.



     <br><dt><code>--version</code>

     <dd>Display the version number and copyrights of the invoked GCC. 

</dl>



   </body></html>



⌨️ 快捷键说明

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