📄 overall-options.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 © 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: <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, compilationproper, assembly and linking, always in that order. GCC is capable ofpreprocessing and compiling several files either into severalassembler input files, or into one assembler input file; then eachassembler input file produces an object file, and linking combines allthe 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 ofcompilation 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 or C++ header file to be turned into a precompiled header. <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>.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>.hh</code> <dd><dt><code></code><var>file</var><code>.H</code> <dd>C++ header file to be turned into a precompiled header. <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 traditionalpreprocessor). <br><dt><code></code><var>file</var><code>.r</code> <dd>Fortran source code which must be preprocessed with a RATFORpreprocessor (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 ofFortran input files. <br><dt><code></code><var>file</var><code>.ads</code> <dd>Ada source code file which contains a library unit declaration (adeclaration of a package, subprogram, or generic, or a genericinstantiation), or a library unit renaming declaration (a package,generic, or subprogram renaming declaration). Such files are alsocalled <dfn>specs</dfn>. <dt><code></code><var>file</var><code>.adb</code> <dd>Ada source code file containing a library unit body (a subprogram orpackage 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 filename suffix). This option applies to all following input files untilthe next <code>-x</code> option. Possible values for <var>language</var> are: <pre class="smallexample"> c c-header cpp-output c++ c++-header c++-cpp-output objective-c objective-c-header 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 arehandled 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 anyphase 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 withnumerically highest error produced by any phase that returned an errorindication. </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, andone 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 linkingstage simply is not done. The ultimate output is in the form of anobject file for each source file. <p>By default, the object file name for a source file is made by replacingthe suffix <code>.c</code>, <code>.i</code>, <code>.s</code>, etc., with <code>.o</code>. <p>Unrecognized input files, not requiring compilation or assembly, areignored. <br><dt><code>-S</code> <dd>Stop after the stage of compilation proper; do not assemble. The outputis in the form of an assembler code file for each non-assembler inputfile specified. <p>By default, the assembler file name for a source file is made byreplacing 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. Theoutput is in the form of preprocessed source code, which is sent to thestandard 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 whateversort of output is being produced, whether it be an executable file,an object file, an assembler file or preprocessed C code. <p>If <code>-o</code> is not specified, the default is to put an executable filein <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>, andall preprocessed C source on standard output. <br><dt><code>-v</code> <dd>Print (on standard error output) the commands executed to run the stagesof compilation. Also print the version number of the compiler driverprogram 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 commandarguments are quoted. This is useful for shell scripts to capture thedriver-generated command lines. <br><dt><code>-pipe</code> <dd>Use pipes rather than temporary files for communication between thevarious stages of compilation. This fails to work on some systems wherethe assembler is unable to read from a pipe; but the GNU assembler hasno trouble. <br><dt><code>-combine</code> <dd>If you are compiling multiple source files, this option tells the driverto pass all the source files to the compiler at once (for thoselanguages for which the compiler can handle this). This will allowintermodule analysis (IMA) to be performed by the compiler. Currently the onlylanguage for which this is supported is C. If you pass source files formultiple languages to the driver, using this option, the driver will invokethe compiler(s) that support IMA once each, passing each compiler all thesource files appropriate for it. For those languages that do not supportIMA this option will be ignored, and the compiler will be invoked once foreach source file in that language. If you use this option in conjunctionwith -save-temps, the compiler will generate multiple pre-processed files(one for each source file), but only one (combined) .o or .s file. <br><dt><code>--help</code> <dd>Print (on the standard output) a description of the command line optionsunderstood by <code>gcc</code>. If the <code>-v</code> option is also specifiedthen <code>--help</code> will also be passed on to the various processesinvoked by <code>gcc</code>, so that they can display the command line optionsthey accept. If the <code>-Wextra</code> option is also specified then commandline options which have no documentation associated with them will alsobe displayed. <br><dt><code>--target-help</code> <dd>Print (on the standard output) a description of target specific commandline 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 + -