?? cppopts.texi
字號:
@c Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007@c Free Software Foundation, Inc.@c This is part of the CPP and GCC manuals.@c For copying conditions, see the file gcc.texi.@c ---------------------------------------------------------------------@c Options affecting the preprocessor@c ---------------------------------------------------------------------@c If this file is included with the flag ``cppmanual'' set, it is@c formatted for inclusion in the CPP manual; otherwise the main GCC manual.@table @gcctabopt@item -D @var{name}@opindex DPredefine @var{name} as a macro, with definition @code{1}.@item -D @var{name}=@var{definition}The contents of @var{definition} are tokenized and processed as ifthey appeared during translation phase three in a @samp{#define}directive. In particular, the definition will be truncated byembedded newline characters.If you are invoking the preprocessor from a shell or shell-likeprogram you may need to use the shell's quoting syntax to protectcharacters such as spaces that have a meaning in the shell syntax.If you wish to define a function-like macro on the command line, writeits argument list with surrounding parentheses before the equals sign(if any). Parentheses are meaningful to most shells, so you will needto quote the option. With @command{sh} and @command{csh},@option{-D'@var{name}(@var{args@dots{}})=@var{definition}'} works.@option{-D} and @option{-U} options are processed in the order theyare given on the command line. All @option{-imacros @var{file}} and@option{-include @var{file}} options are processed after all@option{-D} and @option{-U} options.@item -U @var{name}@opindex UCancel any previous definition of @var{name}, either built in orprovided with a @option{-D} option.@item -undef@opindex undefDo not predefine any system-specific or GCC-specific macros. Thestandard predefined macros remain defined.@ifset cppmanual@xref{Standard Predefined Macros}.@end ifset@item -I @var{dir}@opindex IAdd the directory @var{dir} to the list of directories to be searchedfor header files.@ifset cppmanual@xref{Search Path}.@end ifsetDirectories named by @option{-I} are searched before the standardsystem include directories. If the directory @var{dir} is a standardsystem include directory, the option is ignored to ensure that thedefault search order for system directories and the special treatmentof system headers are not defeated@ifset cppmanual(@pxref{System Headers})@end ifset.If @var{dir} begins with @code{=}, then the @code{=} will be replacedby the sysroot prefix; see @option{--sysroot} and @option{-isysroot}.@item -o @var{file}@opindex oWrite output to @var{file}. This is the same as specifying @var{file}as the second non-option argument to @command{cpp}. @command{gcc} has adifferent interpretation of a second non-option argument, so you mustuse @option{-o} to specify the output file.@item -Wall@opindex WallTurns on all optional warnings which are desirable for normal code.At present this is @option{-Wcomment}, @option{-Wtrigraphs},@option{-Wmultichar} and a warning about integer promotion causing achange of sign in @code{#if} expressions. Note that many of thepreprocessor's warnings are on by default and have no options tocontrol them.@item -Wcomment@itemx -Wcomments@opindex Wcomment@opindex WcommentsWarn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}comment, or whenever a backslash-newline appears in a @samp{//} comment.(Both forms have the same effect.)@item -Wtrigraphs@opindex Wtrigraphs@anchor{Wtrigraphs}Most trigraphs in comments cannot affect the meaning of the program.However, a trigraph that would form an escaped newline (@samp{??/} atthe end of a line) can, by changing where the comment begins or ends.Therefore, only trigraphs that would form escaped newlines producewarnings inside a comment.This option is implied by @option{-Wall}. If @option{-Wall} is notgiven, this option is still enabled unless trigraphs are enabled. Toget trigraph conversion without warnings, but get the other@option{-Wall} warnings, use @samp{-trigraphs -Wall -Wno-trigraphs}.@item -Wtraditional@opindex WtraditionalWarn about certain constructs that behave differently in traditional andISO C@. Also warn about ISO C constructs that have no traditional Cequivalent, and problematic constructs which should be avoided.@ifset cppmanual@xref{Traditional Mode}.@end ifset@item -Wimport@opindex WimportWarn the first time @samp{#import} is used.@item -Wundef@opindex WundefWarn whenever an identifier which is not a macro is encountered in an@samp{#if} directive, outside of @samp{defined}. Such identifiers arereplaced with zero.@item -Wunused-macros@opindex Wunused-macrosWarn about macros defined in the main file that are unused. A macrois @dfn{used} if it is expanded or tested for existence at least once.The preprocessor will also warn if the macro has not been used at thetime it is redefined or undefined.Built-in macros, macros defined on the command line, and macrosdefined in include files are not warned about.@emph{Note:} If a macro is actually used, but only used in skippedconditional blocks, then CPP will report it as unused. To avoid thewarning in such a case, you might improve the scope of the macro'sdefinition by, for example, moving it into the first skipped block.Alternatively, you could provide a dummy use with something like:@smallexample#if defined the_macro_causing_the_warning#endif@end smallexample@item -Wendif-labels@opindex Wendif-labelsWarn whenever an @samp{#else} or an @samp{#endif} are followed by text.This usually happens in code of the form@smallexample#if FOO@dots{}#else FOO@dots{}#endif FOO@end smallexample@noindentThe second and third @code{FOO} should be in comments, but often are notin older programs. This warning is on by default.@item -Werror@opindex WerrorMake all warnings into hard errors. Source code which triggers warningswill be rejected.@item -Wsystem-headers@opindex Wsystem-headersIssue warnings for code in system headers. These are normally unhelpfulin finding bugs in your own code, therefore suppressed. If you areresponsible for the system library, you may want to see them.@item -w@opindex wSuppress all warnings, including those which GNU CPP issues by default.@item -pedantic@opindex pedanticIssue all the mandatory diagnostics listed in the C standard. Some ofthem are left out by default, since they trigger frequently on harmlesscode.@item -pedantic-errors@opindex pedantic-errorsIssue all the mandatory diagnostics, and make all mandatory diagnosticsinto errors. This includes mandatory diagnostics that GCC issueswithout @samp{-pedantic} but treats as warnings.@item -M@opindex M@cindex make@cindex dependencies, makeInstead of outputting the result of preprocessing, output a rulesuitable for @command{make} describing the dependencies of the mainsource file. The preprocessor outputs one @command{make} rule containingthe object file name for that source file, a colon, and the names of allthe included files, including those coming from @option{-include} or@option{-imacros} command line options.Unless specified explicitly (with @option{-MT} or @option{-MQ}), theobject file name consists of the name of the source file with anysuffix replaced with object file suffix and with any leading directoryparts removed. If there are many included files then the rule issplit into several lines using @samp{\}-newline. The rule has nocommands.This option does not suppress the preprocessor's debug output, such as@option{-dM}. To avoid mixing such debug output with the dependencyrules you should explicitly specify the dependency output file with@option{-MF}, or use an environment variable like@env{DEPENDENCIES_OUTPUT} (@pxref{Environment Variables}). Debug outputwill still be sent to the regular output stream as normal.Passing @option{-M} to the driver implies @option{-E}, and suppresseswarnings with an implicit @option{-w}.@item -MM@opindex MMLike @option{-M} but do not mention header files that are found insystem header directories, nor header files that are included,directly or indirectly, from such a header.This implies that the choice of angle brackets or double quotes in an@samp{#include} directive does not in itself determine whether thatheader will appear in @option{-MM} dependency output. This is aslight change in semantics from GCC versions 3.0 and earlier.@anchor{dashMF}@item -MF @var{file}@opindex MFWhen used with @option{-M} or @option{-MM}, specifies afile to write the dependencies to. If no @option{-MF} switch is giventhe preprocessor sends the rules to the same place it would have sentpreprocessed output.When used with the driver options @option{-MD} or @option{-MMD},@option{-MF} overrides the default dependency output file.@item -MG@opindex MGIn conjunction with an option such as @option{-M} requestingdependency generation, @option{-MG} assumes missing header files aregenerated files and adds them to the dependency list without raisingan error. The dependency filename is taken directly from the@code{#include} directive without prepending any path. @option{-MG}also suppresses preprocessed output, as a missing header file rendersthis useless.This feature is used in automatic updating of makefiles.@item -MP@opindex MPThis option instructs CPP to add a phony target for each dependencyother than the main file, causing each to depend on nothing. Thesedummy rules work around errors @command{make} gives if you remove headerfiles without updating the @file{Makefile} to match.This is typical output:@smallexampletest.o: test.c test.htest.h:@end smallexample@item -MT @var{target}@opindex MTChange the target of the rule emitted by dependency generation. Bydefault CPP takes the name of the main input file, deletes anydirectory components and any file suffix such as @samp{.c}, andappends the platform's usual object suffix. The result is the target.An @option{-MT} option will set the target to be exactly the string youspecify. If you want multiple targets, you can specify them as a singleargument to @option{-MT}, or use multiple @option{-MT} options.For example, @option{@w{-MT '$(objpfx)foo.o'}} might give@smallexample$(objpfx)foo.o: foo.c@end smallexample@item -MQ @var{target}@opindex MQSame as @option{-MT}, but it quotes any characters which are special toMake. @option{@w{-MQ '$(objpfx)foo.o'}} gives@smallexample$$(objpfx)foo.o: foo.c@end smallexampleThe default target is automatically quoted, as if it were given with@option{-MQ}.@item -MD@opindex MD@option{-MD} is equivalent to @option{-M -MF @var{file}}, except that@option{-E} is not implied. The driver determines @var{file} based onwhether an @option{-o} option is given. If it is, the driver uses itsargument but with a suffix of @file{.d}, otherwise it takes the nameof the input file, removes any directory components and suffix, andapplies a @file{.d} suffix.If @option{-MD} is used in conjunction with @option{-E}, any@option{-o} switch is understood to specify the dependency output file(@pxref{dashMF,,-MF}), but if used without @option{-E}, each @option{-o}is understood to specify a target object file.Since @option{-E} is not implied, @option{-MD} can be used to generatea dependency output file as a side-effect of the compilation process.@item -MMD@opindex MMDLike @option{-MD} except mention only user header files, not systemheader files.@ifclear cppmanual@item -fpch-deps@opindex fpch-depsWhen using precompiled headers (@pxref{Precompiled Headers}), this flagwill cause the dependency-output flags to also list the files from theprecompiled header's dependencies. If not specified only theprecompiled header would be listed and not the files that were used tocreate it because those files are not consulted when a precompiledheader is used.@item -fpch-preprocess@opindex fpch-preprocessThis option allows use of a precompiled header (@pxref{PrecompiledHeaders}) together with @option{-E}. It inserts a special @code{#pragma},@code{#pragma GCC pch_preprocess "<filename>"} in the output to markthe place where the precompiled header was found, and its filename. When@option{-fpreprocessed} is in use, GCC recognizes this @code{#pragma} andloads the PCH@.This option is off by default, because the resulting preprocessed outputis only really suitable as input to GCC@. It is switched on by@option{-save-temps}.You should not write this @code{#pragma} in your own code, but it issafe to edit the filename if the PCH file is available in a differentlocation. The filename may be absolute or it may be relative to GCC'scurrent directory.@end ifclear@item -x c@itemx -x c++@itemx -x objective-c@itemx -x assembler-with-cpp@opindex xSpecify the source language: C, C++, Objective-C, or assembly. This hasnothing to do with standards conformance or extensions; it merelyselects which base syntax to expect. If you give none of these options,cpp will deduce the language from the extension of the source file:@samp{.c}, @samp{.cc}, @samp{.m}, or @samp{.S}. Some other commonextensions for C++ and assembly are also recognized. If cpp does notrecognize the extension, it will treat the file as C; this is the mostgeneric mode.@emph{Note:} Previous versions of cpp accepted a @option{-lang} optionwhich selected both the language and the standards conformance level.This option has been removed, because it conflicts with the @option{-l}option.@item -std=@var{standard}@itemx -ansi@opindex ansi@opindex std=Specify the standard to which the code should conform. Currently CPPknows about C and C++ standards; others may be added in the future.@var{standard}may be one of:@table @code@item iso9899:1990@itemx c89The ISO C standard from 1990. @samp{c89} is the customary shorthand forthis version of the standard.The @option{-ansi} option is equivalent to @option{-std=c89}.@item iso9899:199409The 1990 C standard, as amended in 1994.@item iso9899:1999@itemx c99
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -