📄 invoke.texi
字号:
the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.Unrecognized input files, not requiring compilation or assembly, areignored.@item -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 -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}Place 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.Since only one output file can be specified, it does not make sense touse @samp{-o} when compiling more than one input file, unless you areproducing an executable file as output.If @samp{-o} is not specified, the default is to put an executable filein @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in@file{@var{source}.o}, its assembler file in @file{@var{source}.s}, andall preprocessed C source on standard output.@refill@item -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 -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.@end table@node Dialect Options@section Options Controlling Dialect@cindex dialect options@cindex language dialect options@cindex options, dialectThe following options control the dialect of C or C++ that the compileraccepts:@table @code@cindex ANSI support@item -ansiSupport all ANSI standard C programs.This turns off certain features of GNU C that are incompatible with ANSIC, such as the @code{asm}, @code{inline} and @code{typeof} keywords, andpredefined macros such as @code{unix} and @code{vax} that identify thetype of system you are using. It also enables the undesirable andrarely used ANSI trigraph feature, and disallows @samp{$} as part ofidentifiers.The alternate keywords @code{__asm__}, @code{__extension__},@code{__inline__} and @code{__typeof__} continue to work despite@samp{-ansi}. You would not want to use them in an ANSI C program, ofcourse, but it useful to put them in header files that might be includedin compilations done with @samp{-ansi}. Alternate predefined macrossuch as @code{__unix__} and @code{__vax__} are also available, with orwithout @samp{-ansi}.The @samp{-ansi} option does not cause non-ANSI programs to berejected gratuitously. For that, @samp{-pedantic} is required inaddition to @samp{-ansi}. @xref{Warning Options}.The macro @code{__STRICT_ANSI__} is predefined when the @samp{-ansi}option is used. Some header files may notice this macro and refrainfrom declaring certain functions or defining certain macros that theANSI standard doesn't call for; this is to avoid interfering with anyprograms that might use these names for other things.The functions @code{alloca}, @code{abort}, @code{exit}, and@code{_exit} are not builtin functions when @samp{-ansi} is used.@item -fall-virtualTreat certain member functions as virtual, implicitly (C++ only). Thisapplies to all member functions declared in the same class with a``method-call'' operator method (except for constructor functions and@code{new} or @code{delete} member operators). In effect, all of thesemethods become ``implicitly virtual.''This does not mean that all calls to these methods will be made throughthe internal table of virtual functions. There are some circumstancesunder which it is obvious that a call to a given virtual function can bemade directly, and in these cases the calls still go direct.The effect of making all methods of a class with a declared@samp{operator->()()} implicitly virtual using @samp{-fall-virtual}extends also to all non-constructor methods of any class derived fromsuch a class.@item -fdollars-in-identifiersPermit the use of @samp{$} in identifiers (C++ only). You can also use@samp{-fno-dollars-in-identifiers} to explicitly prohibit use of@samp{$}. (GNU C++ allows @samp{$} by default on some target systemsbut not others.)@item -fenum-int-equivPermit implicit conversion of @code{int} to enumeration types (C++only). Normally GNU C++ allows conversion of @code{enum} to @code{int},but not the other way around.@item -fno-asmDo not recognize @code{asm}, @code{inline} or @code{typeof} as akeyword. These words may then be used as identifiers. You canuse @code{__asm__}, @code{__inline__} and @code{__typeof__} instead.@samp{-ansi} implies @samp{-fno-asm}.@item -fno-builtinDon't recognize built-in functions that do not begin with two leadingunderscores. Currently, the functions affected include @code{_exit},@code{abort}, @code{abs}, @code{alloca}, @code{cos}, @code{exit},@code{fabs}, @code{labs}, @code{memcmp}, @code{memcpy}, @code{sin},@code{sqrt}, @code{strcmp}, @code{strcpy}, and @code{strlen}.The @samp{-ansi} option prevents @code{alloca} and @code{_exit} frombeing builtin functions.@item -fno-strict-prototypeTreat a function declaration with no arguments, such as @samp{int foo();}, as C would treat it---as saying nothing about the number ofarguments or their types (C++ only). Normally, such a declaration inC++ means that the function @code{foo} takes no arguments.@item -fthis-is-variablePermit assignment to @code{this} (C++ only). The incorporation ofuser-defined free store management into C++ has made assignment to@samp{this} an anachronism. Therefore, by default it is invalid toassign to @code{this} within a class member function. However, forbackwards compatibility, you can make it valid with@samp{-fthis-is-variable}.@item -trigraphsSupport ANSI C trigraphs. You don't want to know about thisbrain-damage. The @samp{-ansi} option implies @samp{-trigraphs}.@cindex traditional C language@cindex C language, traditional@item -traditionalAttempt to support some aspects of traditional C compilers.Specifically:@itemize @bullet@itemAll @code{extern} declarations take effect globally even if theyare written inside of a function definition. This includes implicitdeclarations of functions.@itemThe keywords @code{typeof}, @code{inline}, @code{signed}, @code{const}and @code{volatile} are not recognized. (You can still use thealternative keywords such as @code{__typeof__}, @code{__inline__}, andso on.)@itemComparisons between pointers and integers are always allowed.@itemInteger types @code{unsigned short} and @code{unsigned char} promoteto @code{unsigned int}.@itemOut-of-range floating point literals are not an error.@itemString ``constants'' are not necessarily constant; they are stored inwritable space, and identical looking constants are allocatedseparately. (This is the same as the effect of@samp{-fwritable-strings}.)@cindex @code{longjmp} and automatic variables@itemAll automatic variables not declared @code{register} are preserved by@code{longjmp}. Ordinarily, GNU C follows ANSI C: automatic variablesnot declared @code{volatile} may be clobbered.@itemIn the preprocessor, comments convert to nothing at all, rather thanto a space. This allows traditional token concatenation.@itemIn the preprocessor, macro arguments are recognized within stringconstants in a macro definition (and their values are stringified,though without additional quote marks, when they appear in such acontext). The preprocessor always considers a string constant to endat a newline.@itemThe predefined macro @code{__STDC__} is not defined when you use@samp{-traditional}, but @code{__GNUC__} is (since the GNU extensionswhich @code{__GNUC__} indicates are not affected by@samp{-traditional}). If you need to write header files that workdifferently depending on whether @samp{-traditional} is in use, bytesting both of these predefined macros you can distinguish foursituations: GNU C, traditional GNU C, other ANSI C compilers, andother old C compilers.@end itemizeYou may wish to use @samp{-fno-builtin} as well as @samp{-traditional}if your program uses names that are normally GNU C builtin functions forother purposes of its own.@item -traditional-cppAttempt to support some aspects of traditional C preprocessors.This includes the last three items in the table immediately above,but none of the other effects of @samp{-traditional}.@item -fcond-mismatchAllow conditional expressions with mismatched types in the second andthird arguments. The value of such an expression is void.@item -funsigned-charLet the type @code{char} be unsigned, like @code{unsigned char}.Each kind of machine has a default for what @code{char} shouldbe. It is either like @code{unsigned char} by default or like@code{signed char} by default.Ideally, a portable program should always use @code{signed char} or@code{unsigned char} when it depends on the signedness of an object.But many programs have been written to use plain @code{char} andexpect it to be signed, or expect it to be unsigned, depending on themachines they were written for. This option, and its inverse, let youmake such a program work with the opposite default.The type @code{char} is always a distinct type from each of@code{signed char} or @code{unsigned char}, even though its behavioris always just like one of those two.@item -fsigned-charLet the type @code{char} be signed, like @code{signed char}.Note that this is equivalent to @samp{-fno-unsigned-char}, which isthe negative form of @samp{-funsigned-char}. Likewise,@samp{-fno-signed-char} is equivalent to @samp{-funsigned-char}.@item -fsigned-bitfields@itemx -funsigned-bitfields@itemx -fno-signed-bitfields@itemx -fno-unsigned-bitfieldsThese options control whether a bitfield is signed or unsigned, when thedeclaration does not use either @code{signed} or @code{unsigned}. Bydefault, such a bitfield is signed, because this is consistent: thebasic integer types such as @code{int} are signed types.However, when @samp{-traditional} is used, bitfields are all unsignedno matter what.@item -fwritable-stringsStore string constants in the writable data segment and don't uniquizethem. This is for compatibility with old programs which assume theycan write into string constants. @samp{-traditional} also has thiseffect.Writing into string constants is a very bad idea; ``constants'' shouldbe constant.@end table@node Warning Options@section Options to Request or Suppress Warnings@cindex options to control warnings@cindex warning messages@cindex messages, warning@cindex suppressing warningsWarnings are diagnostic messages that report constructions whichare not inherently erroneous but which are risky or suggest theremay have been an error.You can request many specific warnings with options beginning @samp{-W},for example @samp{-Wimplicit} to request warnings on implicitdeclarations. Each of these specific warning options also has anegative form beginning @samp{-Wno-} to turn off warnings;for example, @samp{-Wno-implicit}. This manual lists only one of thetwo forms, whichever is not the default.These options control the amount and kinds of warnings produced by GNUCC:@table @code@cindex syntax checking@item -fsyntax-onlyCheck the code for syntax errors, but don't emit any output.@item -wInhibit all warning messages.@item -Wno-importInhibit warning messages about the use of @samp{#import}.@item -pedanticIssue all the warnings demanded by strict ANSI standard C; rejectall programs that use forbidden extensions. Valid ANSI standard C programs should compile properly with or withoutthis option (though a rare few will require @samp{-ansi}). However,without this option, certain GNU extensions and traditional C featuresare supported as well. With this option, they are rejected.@samp{-pedantic} does not cause warning messages for use of thealternate keywords whose names begin and end with @samp{__}. Pedanticwarnings are also disabled in the expression that follows@code{__extension__}. However, only system header files should usethese escape routes; application programs should avoid them.@xref{Alternate Keywords}.This option is not intended to be @i{useful}; it exists only to satisfypedants who would otherwise claim that GNU CC fails to support the ANSIstandard.Some users try to use @samp{-pedantic} to check programs for strict ANSIC conformance. They soon find that it does not do quite what they want:it finds some non-ANSI practices, but not all---only those for whichANSI C @emph{requires} a diagnostic.A feature to report any failure to conform to ANSI C might be useful insome instances, but would require considerable additional work and wouldbe quite different from @samp{-pedantic}. We recommend, rather, thatusers take advantage of the extensions of GNU C and disregard thelimitations of other compilers. Aside from certain supercomputers andobsolete small machines, there is less and less reason ever to use anyother C compiler other than for bootstrapping GNU CC.@item -pedantic-errorsLike @samp{-pedantic}, except that errors are produced rather thanwarnings.@item -WPrint extra warning messages for these events:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -