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

📄 invoke.texi

📁 理解和实践操作系统的一本好书
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
Ada source code file containing a library unit body (a subprogram orpackage body).  Such files are also called @dfn{bodies}.@c GCC also knows about some suffixes for languages not yet included:@c Pascal:@c @var{file}.p@c @var{file}.pas@c Ratfor:@c @var{file}.r@item @var{file}.sAssembler code.@item @var{file}.S@itemx @var{file}.sxAssembler code which must be preprocessed.@item @var{other}An object file to be fed straight into linking.Any file name with no recognized suffix is treated this way.@end table@opindex xYou can specify the input language explicitly with the @option{-x} option:@table @gcctabopt@item -x @var{language}Specify explicitly the @var{language} 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 @option{-x} option.  Possible values for @var{language} are:@smallexamplec  c-header  c-cpp-outputc++  c++-header  c++-cpp-outputobjective-c  objective-c-header  objective-c-cpp-outputobjective-c++ objective-c++-header objective-c++-cpp-outputassembler  assembler-with-cppadaf95  f95-cpp-inputjavatreelang@end smallexample@item -x noneTurn off any specification of a language, so that subsequent files arehandled according to their file name suffixes (as they are if @option{-x}has not been used at all).@item -pass-exit-codes@opindex pass-exit-codesNormally the @command{gcc} program will exit with the code of 1 if anyphase of the compiler returns a non-success return code.  If you specify@option{-pass-exit-codes}, the @command{gcc} program will instead return withnumerically highest error produced by any phase that returned an errorindication.  The C, C++, and Fortran frontends return 4, if an internalcompiler error is encountered.@end tableIf you only want some of the stages of compilation, you can use@option{-x} (or filename suffixes) to tell @command{gcc} where to start, andone of the options @option{-c}, @option{-S}, or @option{-E} to say where@command{gcc} is to stop.  Note that some combinations (for example,@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.@table @gcctabopt@item -c@opindex cCompile 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.By default, the object file name for a source file is made by replacingthe suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.Unrecognized input files, not requiring compilation or assembly, areignored.@item -S@opindex SStop 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.By default, the assembler file name for a source file is made byreplacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.Input files that don't require compilation are ignored.@item -E@opindex EStop 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.Input files which don't require preprocessing are ignored.@cindex output file option@item -o @var{file}@opindex oPlace output in file @var{file}.  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.If @option{-o} is not specified, the default is to put an executablefile in @file{a.out}, the object file for@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, itsassembler file in @file{@var{source}.s}, a precompiled header file in@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source onstandard output.@item -v@opindex vPrint (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.@item -###@opindex ###Like @option{-v} except the commands are not executed and all commandarguments are quoted.  This is useful for shell scripts to capture thedriver-generated command lines.@item -pipe@opindex pipeUse 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.@item -combine@opindex combineIf 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 @option{-save-temps}, the compiler will generate multiplepre-processed files(one for each source file), but only one (combined) @file{.o} or@file{.s} file.@item --help@opindex helpPrint (on the standard output) a description of the command line optionsunderstood by @command{gcc}.  If the @option{-v} option is also specifiedthen @option{--help} will also be passed on to the various processesinvoked by @command{gcc}, so that they can display the command line optionsthey accept.  If the @option{-Wextra} option has also been specified(prior to the @option{--help} option), then command line options whichhave no documentation associated with them will also be displayed.@item --target-help@opindex target-helpPrint (on the standard output) a description of target-specific commandline options for each tool.  For some targets extra target-specificinformation may also be printed.@item --help=@var{class}@r{[},@var{qualifier}@r{]}Print (on the standard output) a description of the command lineoptions understood by the compiler that fit into a specific class.The class can be one of @samp{optimizers}, @samp{warnings}, @samp{target},@samp{params}, or @var{language}:@table @asis@item @samp{optimizers}This will display all of the optimization options supported by thecompiler.@item @samp{warnings}This will display all of the options controlling warning messagesproduced by the compiler.@item @samp{target}This will display target-specific options.  Unlike the@option{--target-help} option however, target-specific options of thelinker and assembler will not be displayed.  This is because thosetools do not currently support the extended @option{--help=} syntax.@item @samp{params}This will display the values recognized by the @option{--param}option.@item @var{language}This will display the options supported for @var{language}, where @var{language} is the name of one of the languages supported in this version of GCC.@item @samp{common}This will display the options that are common to all languages.@end tableIt is possible to further refine the output of the @option{--help=}option by adding a comma separated list of qualifiers after theclass.  These can be any from the following list:@table @asis@item @samp{undocumented}Display only those options which are undocumented.@item @samp{joined}Display options which take an argument that appears after an equalsign in the same continuous piece of text, such as:@samp{--help=target}.@item @samp{separate}Display options which take an argument that appears as a separate wordfollowing the original option, such as: @samp{-o output-file}.@end tableThus for example to display all the undocumented target-specificswitches supported by the compiler the following can be used:@smallexample--help=target,undocumented@end smallexampleThe sense of a qualifier can be inverted by prefixing it with the@var{^} character, so for example to display all binary warningoptions (i.e., ones that are either on or off and that do not take anargument), which have a description the following can be used:@smallexample--help=warnings,^joined,^undocumented@end smallexampleA class can also be used as a qualifier, although this usuallyrestricts the output by so much that there is nothing to display.  Onecase where it does work however is when one of the classes is@var{target}.  So for example to display all the target-specificoptimization options the following can be used:@smallexample--help=target,optimizers@end smallexampleThe @option{--help=} option can be repeated on the command line.  Eachsuccessive use will display its requested class of options, skippingthose that have already been displayed.If the @option{-Q} option appears on the command line before the@option{--help=} option, then the descriptive text displayed by@option{--help=} is changed.  Instead of describing the displayedoptions, an indication is given as to whether the option is enabled,disabled or set to a specific value (assuming that the compilerknows this at the point where the @option{--help=} option is used).Here is a truncated example from the ARM port of @command{gcc}:@smallexample  % gcc -Q -mabi=2 --help=target -c  The following options are target specific:  -mabi=                                2  -mabort-on-noreturn                   [disabled]  -mapcs                                [disabled]@end smallexampleThe output is sensitive to the effects of previous command lineoptions, so for example it is possible to find out which optimizationsare enabled at @option{-O2} by using:@smallexample-O2 --help=optimizers@end smallexampleAlternatively you can discover which binary optimizations are enabledby @option{-O3} by using:@smallexamplegcc -c -Q -O3 --help=optimizers > /tmp/O3-optsgcc -c -Q -O2 --help=optimizers > /tmp/O2-optsdiff /tmp/O2-opts /tmp/O3-opts | grep enabled@end smallexample@item --version@opindex versionDisplay the version number and copyrights of the invoked GCC@.@include @value{srcdir}/../libiberty/at-file.texi@end table@node Invoking G++@section Compiling C++ Programs@cindex suffixes for C++ source@cindex C++ source file suffixesC++ source files conventionally use one of the suffixes @samp{.C},@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},@samp{.H}, or (for shared template code) @samp{.tcc}; andpreprocessed C++ files use the suffix @samp{.ii}.  GCC recognizesfiles with these names and compiles them as C++ programs even if youcall the compiler the same way as for compiling C programs (usuallywith the name @command{gcc}).@findex g++@findex c++However, the use of @command{gcc} does not add the C++ library.@command{g++} is a program that calls GCC and treats @samp{.c},@samp{.h} and @samp{.i} files as C++ source files instead of C sourcefiles unless @option{-x} is used, and automatically specifies linkingagainst the C++ library.  This program is also useful whenprecompiling a C header file with a @samp{.h} extension for use in C++compilations.  On many systems, @command{g++} is also installed withthe name @command{c++}.@cindex invoking @command{g++}When you compile C++ programs, you may specify many of the samecommand-line options that you use for compiling programs in anylanguage; or command-line options meaningful for C and relatedlanguages; or options that are meaningful only for C++ programs.@xref{C Dialect Options,,Options Controlling C Dialect}, forexplanations of options for languages related to C@.@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, forexplanations of options that are meaningful only for C++ programs.

⌨️ 快捷键说明

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