|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!-- Copyright (C) 1987-2020 Free Software Foundation, Inc.
-
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3 or
- any later version published by the Free Software Foundation. A copy of
- the license is included in the
- section entitled "GNU Free Documentation License".
-
- This manual contains no Invariant Sections. The Front-Cover Texts are
- (a) (see below), and the Back-Cover Texts are (b) (see below).
-
- (a) The FSF's Front-Cover Text is:
-
- A GNU Manual
-
- (b) The FSF's Back-Cover Text is:
-
- 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. -->
- <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Invocation (The C Preprocessor)</title>
-
- <meta name="description" content="Invocation (The C Preprocessor)">
- <meta name="keywords" content="Invocation (The C Preprocessor)">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="makeinfo">
- <link href="index.html#Top" rel="start" title="Top">
- <link href="Index-of-Directives.html#Index-of-Directives" rel="index" title="Index of Directives">
- <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
- <link href="index.html#Top" rel="up" title="Top">
- <link href="Environment-Variables.html#Environment-Variables" rel="next" title="Environment Variables">
- <link href="Obsolete-Features.html#Obsolete-Features" rel="prev" title="Obsolete Features">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.indentedblock {margin-right: 0em}
- blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
- blockquote.smallquotation {font-size: smaller}
- div.display {margin-left: 3.2em}
- div.example {margin-left: 3.2em}
- div.lisp {margin-left: 3.2em}
- div.smalldisplay {margin-left: 3.2em}
- div.smallexample {margin-left: 3.2em}
- div.smalllisp {margin-left: 3.2em}
- kbd {font-style: oblique}
- pre.display {font-family: inherit}
- pre.format {font-family: inherit}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: inherit; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: inherit; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.nolinebreak {white-space: nowrap}
- span.roman {font-family: initial; font-weight: normal}
- span.sansserif {font-family: sans-serif; font-weight: normal}
- ul.no-bullet {list-style: none}
- -->
- </style>
-
-
- </head>
-
- <body lang="en">
- <a name="Invocation"></a>
- <div class="header">
- <p>
- Next: <a href="Environment-Variables.html#Environment-Variables" accesskey="n" rel="next">Environment Variables</a>, Previous: <a href="Implementation-Details.html#Implementation-Details" accesskey="p" rel="prev">Implementation Details</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html#Index-of-Directives" title="Index" rel="index">Index</a>]</p>
- </div>
- <hr>
- <a name="Invocation-1"></a>
- <h2 class="chapter">12 Invocation</h2>
- <a name="index-invocation"></a>
- <a name="index-command-line"></a>
-
- <p>Most often when you use the C preprocessor you do not have to invoke it
- explicitly: the C compiler does so automatically. However, the
- preprocessor is sometimes useful on its own. You can invoke the
- preprocessor either with the <code>cpp</code> command, or via <code>gcc -E</code>.
- In GCC, the preprocessor is actually integrated with the compiler
- rather than a separate program, and both of these commands invoke
- GCC and tell it to stop after the preprocessing phase.
- </p>
- <p>The <code>cpp</code> options listed here are also accepted by
- <code>gcc</code> and have the same meaning. Likewise the <code>cpp</code>
- command accepts all the usual <code>gcc</code> driver options, although those
- pertaining to compilation phases after preprocessing are ignored.
- </p>
- <p>Only options specific to preprocessing behavior are documented here.
- Refer to the GCC manual for full documentation of other driver options.
- </p>
-
- <p>The <code>cpp</code> command expects two file names as arguments, <var>infile</var> and
- <var>outfile</var>. The preprocessor reads <var>infile</var> together with any
- other files it specifies with ‘<samp>#include</samp>’. All the output generated
- by the combined input files is written in <var>outfile</var>.
- </p>
- <p>Either <var>infile</var> or <var>outfile</var> may be <samp>-</samp>, which as
- <var>infile</var> means to read from standard input and as <var>outfile</var>
- means to write to standard output. If either file is omitted, it
- means the same as if <samp>-</samp> had been specified for that file.
- You can also use the <samp>-o <var>outfile</var></samp> option to specify the
- output file.
- </p>
- <p>Unless otherwise noted, or the option ends in ‘<samp>=</samp>’, all options
- which take an argument may have that argument appear either immediately
- after the option, or with a space between option and argument:
- <samp>-Ifoo</samp> and <samp>-I foo</samp> have the same effect.
- </p>
- <a name="index-grouping-options"></a>
- <a name="index-options_002c-grouping"></a>
- <p>Many options have multi-letter names; therefore multiple single-letter
- options may <em>not</em> be grouped: <samp>-dM</samp> is very different from
- ‘<samp><span class="nolinebreak">-d</span> <span class="nolinebreak">-M</span></samp>’<!-- /@w -->.
- </p>
- <a name="index-options"></a>
-
- <dl compact="compact">
- <dt><code>-D <var>name</var></code></dt>
- <dd><a name="index-D"></a>
- <p>Predefine <var>name</var> as a macro, with definition <code>1</code>.
- </p>
- </dd>
- <dt><code>-D <var>name</var>=<var>definition</var></code></dt>
- <dd><p>The contents of <var>definition</var> are tokenized and processed as if
- they appeared during translation phase three in a ‘<samp>#define</samp>’
- directive. In particular, the definition is truncated by
- embedded newline characters.
- </p>
- <p>If you are invoking the preprocessor from a shell or shell-like
- program you may need to use the shell’s quoting syntax to protect
- characters such as spaces that have a meaning in the shell syntax.
- </p>
- <p>If you wish to define a function-like macro on the command line, write
- its argument list with surrounding parentheses before the equals sign
- (if any). Parentheses are meaningful to most shells, so you should
- quote the option. With <code>sh</code> and <code>csh</code>,
- <samp>-D'<var>name</var>(<var>args…</var>)=<var>definition</var>'</samp> works.
- </p>
- <p><samp>-D</samp> and <samp>-U</samp> options are processed in the order they
- are given on the command line. All <samp>-imacros <var>file</var></samp> and
- <samp>-include <var>file</var></samp> options are processed after all
- <samp>-D</samp> and <samp>-U</samp> options.
- </p>
- </dd>
- <dt><code>-U <var>name</var></code></dt>
- <dd><a name="index-U"></a>
- <p>Cancel any previous definition of <var>name</var>, either built in or
- provided with a <samp>-D</samp> option.
- </p>
- </dd>
- <dt><code>-include <var>file</var></code></dt>
- <dd><a name="index-include"></a>
- <p>Process <var>file</var> as if <code>#include "file"</code> appeared as the first
- line of the primary source file. However, the first directory searched
- for <var>file</var> is the preprocessor’s working directory <em>instead of</em>
- the directory containing the main source file. If not found there, it
- is searched for in the remainder of the <code>#include "…"</code> search
- chain as normal.
- </p>
- <p>If multiple <samp>-include</samp> options are given, the files are included
- in the order they appear on the command line.
- </p>
- </dd>
- <dt><code>-imacros <var>file</var></code></dt>
- <dd><a name="index-imacros"></a>
- <p>Exactly like <samp>-include</samp>, except that any output produced by
- scanning <var>file</var> is thrown away. Macros it defines remain defined.
- This allows you to acquire all the macros from a header without also
- processing its declarations.
- </p>
- <p>All files specified by <samp>-imacros</samp> are processed before all files
- specified by <samp>-include</samp>.
- </p>
- </dd>
- <dt><code>-undef</code></dt>
- <dd><a name="index-undef"></a>
- <p>Do not predefine any system-specific or GCC-specific macros. The
- standard predefined macros remain defined.
- See <a href="Standard-Predefined-Macros.html#Standard-Predefined-Macros">Standard Predefined Macros</a>.
- </p>
- </dd>
- <dt><code>-pthread</code></dt>
- <dd><a name="index-pthread"></a>
- <p>Define additional macros required for using the POSIX threads library.
- You should use this option consistently for both compilation and linking.
- This option is supported on GNU/Linux targets, most other Unix derivatives,
- and also on x86 Cygwin and MinGW targets.
- </p>
- </dd>
- <dt><code>-M</code></dt>
- <dd><a name="index-M"></a>
- <a name="index-make"></a>
- <a name="index-dependencies_002c-make"></a>
- <p>Instead of outputting the result of preprocessing, output a rule
- suitable for <code>make</code> describing the dependencies of the main
- source file. The preprocessor outputs one <code>make</code> rule containing
- the object file name for that source file, a colon, and the names of all
- the included files, including those coming from <samp>-include</samp> or
- <samp>-imacros</samp> command-line options.
- </p>
- <p>Unless specified explicitly (with <samp>-MT</samp> or <samp>-MQ</samp>), the
- object file name consists of the name of the source file with any
- suffix replaced with object file suffix and with any leading directory
- parts removed. If there are many included files then the rule is
- split into several lines using ‘<samp>\</samp>’-newline. The rule has no
- commands.
- </p>
- <p>This option does not suppress the preprocessor’s debug output, such as
- <samp>-dM</samp>. To avoid mixing such debug output with the dependency
- rules you should explicitly specify the dependency output file with
- <samp>-MF</samp>, or use an environment variable like
- <code>DEPENDENCIES_OUTPUT</code> (see <a href="Environment-Variables.html#Environment-Variables">Environment Variables</a>). Debug output
- is still sent to the regular output stream as normal.
- </p>
- <p>Passing <samp>-M</samp> to the driver implies <samp>-E</samp>, and suppresses
- warnings with an implicit <samp>-w</samp>.
- </p>
- </dd>
- <dt><code>-MM</code></dt>
- <dd><a name="index-MM"></a>
- <p>Like <samp>-M</samp> but do not mention header files that are found in
- system header directories, nor header files that are included,
- directly or indirectly, from such a header.
- </p>
- <p>This implies that the choice of angle brackets or double quotes in an
- ‘<samp>#include</samp>’ directive does not in itself determine whether that
- header appears in <samp>-MM</samp> dependency output.
- </p>
- <a name="dashMF"></a></dd>
- <dt><code>-MF <var>file</var></code></dt>
- <dd><a name="index-MF"></a>
- <p>When used with <samp>-M</samp> or <samp>-MM</samp>, specifies a
- file to write the dependencies to. If no <samp>-MF</samp> switch is given
- the preprocessor sends the rules to the same place it would send
- preprocessed output.
- </p>
- <p>When used with the driver options <samp>-MD</samp> or <samp>-MMD</samp>,
- <samp>-MF</samp> overrides the default dependency output file.
- </p>
- <p>If <var>file</var> is <samp>-</samp>, then the dependencies are written to <samp>stdout</samp>.
- </p>
- </dd>
- <dt><code>-MG</code></dt>
- <dd><a name="index-MG"></a>
- <p>In conjunction with an option such as <samp>-M</samp> requesting
- dependency generation, <samp>-MG</samp> assumes missing header files are
- generated files and adds them to the dependency list without raising
- an error. The dependency filename is taken directly from the
- <code>#include</code> directive without prepending any path. <samp>-MG</samp>
- also suppresses preprocessed output, as a missing header file renders
- this useless.
- </p>
- <p>This feature is used in automatic updating of makefiles.
- </p>
- </dd>
- <dt><code>-MP</code></dt>
- <dd><a name="index-MP"></a>
- <p>This option instructs CPP to add a phony target for each dependency
- other than the main file, causing each to depend on nothing. These
- dummy rules work around errors <code>make</code> gives if you remove header
- files without updating the <samp>Makefile</samp> to match.
- </p>
- <p>This is typical output:
- </p>
- <div class="smallexample">
- <pre class="smallexample">test.o: test.c test.h
-
- test.h:
- </pre></div>
-
- </dd>
- <dt><code>-MT <var>target</var></code></dt>
- <dd><a name="index-MT"></a>
-
- <p>Change the target of the rule emitted by dependency generation. By
- default CPP takes the name of the main input file, deletes any
- directory components and any file suffix such as ‘<samp>.c</samp>’, and
- appends the platform’s usual object suffix. The result is the target.
- </p>
- <p>An <samp>-MT</samp> option sets the target to be exactly the string you
- specify. If you want multiple targets, you can specify them as a single
- argument to <samp>-MT</samp>, or use multiple <samp>-MT</samp> options.
- </p>
- <p>For example, <samp><span class="nolinebreak">-MT</span> '$(objpfx)foo.o'<!-- /@w --></samp> might give
- </p>
- <div class="smallexample">
- <pre class="smallexample">$(objpfx)foo.o: foo.c
- </pre></div>
-
- </dd>
- <dt><code>-MQ <var>target</var></code></dt>
- <dd><a name="index-MQ"></a>
-
- <p>Same as <samp>-MT</samp>, but it quotes any characters which are special to
- Make. <samp><span class="nolinebreak">-MQ</span> '$(objpfx)foo.o'<!-- /@w --></samp> gives
- </p>
- <div class="smallexample">
- <pre class="smallexample">$$(objpfx)foo.o: foo.c
- </pre></div>
-
- <p>The default target is automatically quoted, as if it were given with
- <samp>-MQ</samp>.
- </p>
- </dd>
- <dt><code>-MD</code></dt>
- <dd><a name="index-MD"></a>
- <p><samp>-MD</samp> is equivalent to <samp>-M -MF <var>file</var></samp>, except that
- <samp>-E</samp> is not implied. The driver determines <var>file</var> based on
- whether an <samp>-o</samp> option is given. If it is, the driver uses its
- argument but with a suffix of <samp>.d</samp>, otherwise it takes the name
- of the input file, removes any directory components and suffix, and
- applies a <samp>.d</samp> suffix.
- </p>
- <p>If <samp>-MD</samp> is used in conjunction with <samp>-E</samp>, any
- <samp>-o</samp> switch is understood to specify the dependency output file
- (see <a href="#dashMF">-MF</a>), but if used without <samp>-E</samp>, each <samp>-o</samp>
- is understood to specify a target object file.
- </p>
- <p>Since <samp>-E</samp> is not implied, <samp>-MD</samp> can be used to generate
- a dependency output file as a side effect of the compilation process.
- </p>
- </dd>
- <dt><code>-MMD</code></dt>
- <dd><a name="index-MMD"></a>
- <p>Like <samp>-MD</samp> except mention only user header files, not system
- header files.
- </p>
- </dd>
- <dt><code>-fpreprocessed</code></dt>
- <dd><a name="index-fpreprocessed"></a>
- <p>Indicate to the preprocessor that the input file has already been
- preprocessed. This suppresses things like macro expansion, trigraph
- conversion, escaped newline splicing, and processing of most directives.
- The preprocessor still recognizes and removes comments, so that you can
- pass a file preprocessed with <samp>-C</samp> to the compiler without
- problems. In this mode the integrated preprocessor is little more than
- a tokenizer for the front ends.
- </p>
- <p><samp>-fpreprocessed</samp> is implicit if the input file has one of the
- extensions ‘<samp>.i</samp>’, ‘<samp>.ii</samp>’ or ‘<samp>.mi</samp>’. These are the
- extensions that GCC uses for preprocessed files created by
- <samp>-save-temps</samp>.
- </p>
- </dd>
- <dt><code>-fdirectives-only</code></dt>
- <dd><a name="index-fdirectives_002donly"></a>
- <p>When preprocessing, handle directives, but do not expand macros.
- </p>
- <p>The option’s behavior depends on the <samp>-E</samp> and <samp>-fpreprocessed</samp>
- options.
- </p>
- <p>With <samp>-E</samp>, preprocessing is limited to the handling of directives
- such as <code>#define</code>, <code>#ifdef</code>, and <code>#error</code>. Other
- preprocessor operations, such as macro expansion and trigraph
- conversion are not performed. In addition, the <samp>-dD</samp> option is
- implicitly enabled.
- </p>
- <p>With <samp>-fpreprocessed</samp>, predefinition of command line and most
- builtin macros is disabled. Macros such as <code>__LINE__</code>, which are
- contextually dependent, are handled normally. This enables compilation of
- files previously preprocessed with <code>-E -fdirectives-only</code>.
- </p>
- <p>With both <samp>-E</samp> and <samp>-fpreprocessed</samp>, the rules for
- <samp>-fpreprocessed</samp> take precedence. This enables full preprocessing of
- files previously preprocessed with <code>-E -fdirectives-only</code>.
- </p>
- </dd>
- <dt><code>-fdollars-in-identifiers</code></dt>
- <dd><a name="index-fdollars_002din_002didentifiers"></a>
- <a name="fdollars_002din_002didentifiers"></a><p>Accept ‘<samp>$</samp>’ in identifiers.
- See <a href="Implementation_002ddefined-behavior.html#Identifier-characters">Identifier characters</a>.
- </p>
- </dd>
- <dt><code>-fextended-identifiers</code></dt>
- <dd><a name="index-fextended_002didentifiers"></a>
- <p>Accept universal character names and extended characters in
- identifiers. This option is enabled by default for C99 (and later C
- standard versions) and C++.
- </p>
- </dd>
- <dt><code>-fno-canonical-system-headers</code></dt>
- <dd><a name="index-fno_002dcanonical_002dsystem_002dheaders"></a>
- <p>When preprocessing, do not shorten system header paths with canonicalization.
- </p>
- </dd>
- <dt><code>-fmax-include-depth=<var>depth</var></code></dt>
- <dd><a name="index-fmax_002dinclude_002ddepth"></a>
- <p>Set the maximum depth of the nested #include. The default is 200.
- </p>
- </dd>
- <dt><code>-ftabstop=<var>width</var></code></dt>
- <dd><a name="index-ftabstop"></a>
- <p>Set the distance between tab stops. This helps the preprocessor report
- correct column numbers in warnings or errors, even if tabs appear on the
- line. If the value is less than 1 or greater than 100, the option is
- ignored. The default is 8.
- </p>
- </dd>
- <dt><code>-ftrack-macro-expansion<span class="roman">[</span>=<var>level</var><span class="roman">]</span></code></dt>
- <dd><a name="index-ftrack_002dmacro_002dexpansion"></a>
- <p>Track locations of tokens across macro expansions. This allows the
- compiler to emit diagnostic about the current macro expansion stack
- when a compilation error occurs in a macro expansion. Using this
- option makes the preprocessor and the compiler consume more
- memory. The <var>level</var> parameter can be used to choose the level of
- precision of token location tracking thus decreasing the memory
- consumption if necessary. Value ‘<samp>0</samp>’ of <var>level</var> de-activates
- this option. Value ‘<samp>1</samp>’ tracks tokens locations in a
- degraded mode for the sake of minimal memory overhead. In this mode
- all tokens resulting from the expansion of an argument of a
- function-like macro have the same location. Value ‘<samp>2</samp>’ tracks
- tokens locations completely. This value is the most memory hungry.
- When this option is given no argument, the default parameter value is
- ‘<samp>2</samp>’.
- </p>
- <p>Note that <code>-ftrack-macro-expansion=2</code> is activated by default.
- </p>
- </dd>
- <dt><code>-fmacro-prefix-map=<var>old</var>=<var>new</var></code></dt>
- <dd><a name="index-fmacro_002dprefix_002dmap"></a>
- <p>When preprocessing files residing in directory <samp><var>old</var></samp>,
- expand the <code>__FILE__</code> and <code>__BASE_FILE__</code> macros as if the
- files resided in directory <samp><var>new</var></samp> instead. This can be used
- to change an absolute path to a relative path by using <samp>.</samp> for
- <var>new</var> which can result in more reproducible builds that are
- location independent. This option also affects
- <code>__builtin_FILE()</code> during compilation. See also
- <samp>-ffile-prefix-map</samp>.
- </p>
- </dd>
- <dt><code>-fexec-charset=<var>charset</var></code></dt>
- <dd><a name="index-fexec_002dcharset"></a>
- <a name="index-character-set_002c-execution"></a>
- <p>Set the execution character set, used for string and character
- constants. The default is UTF-8. <var>charset</var> can be any encoding
- supported by the system’s <code>iconv</code> library routine.
- </p>
- </dd>
- <dt><code>-fwide-exec-charset=<var>charset</var></code></dt>
- <dd><a name="index-fwide_002dexec_002dcharset"></a>
- <a name="index-character-set_002c-wide-execution"></a>
- <p>Set the wide execution character set, used for wide string and
- character constants. The default is UTF-32 or UTF-16, whichever
- corresponds to the width of <code>wchar_t</code>. As with
- <samp>-fexec-charset</samp>, <var>charset</var> can be any encoding supported
- by the system’s <code>iconv</code> library routine; however, you will have
- problems with encodings that do not fit exactly in <code>wchar_t</code>.
- </p>
- </dd>
- <dt><code>-finput-charset=<var>charset</var></code></dt>
- <dd><a name="index-finput_002dcharset"></a>
- <a name="index-character-set_002c-input"></a>
- <p>Set the input character set, used for translation from the character
- set of the input file to the source character set used by GCC. If the
- locale does not specify, or GCC cannot get this information from the
- locale, the default is UTF-8. This can be overridden by either the locale
- or this command-line option. Currently the command-line option takes
- precedence if there’s a conflict. <var>charset</var> can be any encoding
- supported by the system’s <code>iconv</code> library routine.
- </p>
-
- </dd>
- <dt><code>-fworking-directory</code></dt>
- <dd><a name="index-fworking_002ddirectory"></a>
- <a name="index-fno_002dworking_002ddirectory"></a>
- <p>Enable generation of linemarkers in the preprocessor output that
- let the compiler know the current working directory at the time of
- preprocessing. When this option is enabled, the preprocessor
- emits, after the initial linemarker, a second linemarker with the
- current working directory followed by two slashes. GCC uses this
- directory, when it’s present in the preprocessed input, as the
- directory emitted as the current working directory in some debugging
- information formats. This option is implicitly enabled if debugging
- information is enabled, but this can be inhibited with the negated
- form <samp>-fno-working-directory</samp>. If the <samp>-P</samp> flag is
- present in the command line, this option has no effect, since no
- <code>#line</code> directives are emitted whatsoever.
- </p>
- </dd>
- <dt><code>-A <var>predicate</var>=<var>answer</var></code></dt>
- <dd><a name="index-A"></a>
- <p>Make an assertion with the predicate <var>predicate</var> and answer
- <var>answer</var>. This form is preferred to the older form <samp>-A
- <var>predicate</var>(<var>answer</var>)</samp>, which is still supported, because
- it does not use shell special characters.
- See <a href="Obsolete-Features.html#Obsolete-Features">Obsolete Features</a>.
- </p>
- </dd>
- <dt><code>-A -<var>predicate</var>=<var>answer</var></code></dt>
- <dd><p>Cancel an assertion with the predicate <var>predicate</var> and answer
- <var>answer</var>.
- </p>
- </dd>
- <dt><code>-C</code></dt>
- <dd><a name="index-C"></a>
- <p>Do not discard comments. All comments are passed through to the output
- file, except for comments in processed directives, which are deleted
- along with the directive.
- </p>
- <p>You should be prepared for side effects when using <samp>-C</samp>; it
- causes the preprocessor to treat comments as tokens in their own right.
- For example, comments appearing at the start of what would be a
- directive line have the effect of turning that line into an ordinary
- source line, since the first token on the line is no longer a ‘<samp>#</samp>’.
- </p>
- </dd>
- <dt><code>-CC</code></dt>
- <dd><a name="index-CC"></a>
- <p>Do not discard comments, including during macro expansion. This is
- like <samp>-C</samp>, except that comments contained within macros are
- also passed through to the output file where the macro is expanded.
- </p>
- <p>In addition to the side effects of the <samp>-C</samp> option, the
- <samp>-CC</samp> option causes all C++-style comments inside a macro
- to be converted to C-style comments. This is to prevent later use
- of that macro from inadvertently commenting out the remainder of
- the source line.
- </p>
- <p>The <samp>-CC</samp> option is generally used to support lint comments.
- </p>
- </dd>
- <dt><code>-P</code></dt>
- <dd><a name="index-P"></a>
- <p>Inhibit generation of linemarkers in the output from the preprocessor.
- This might be useful when running the preprocessor on something that is
- not C code, and will be sent to a program which might be confused by the
- linemarkers.
- See <a href="Preprocessor-Output.html#Preprocessor-Output">Preprocessor Output</a>.
- </p>
- <a name="index-traditional-C-language"></a>
- <a name="index-C-language_002c-traditional"></a>
- </dd>
- <dt><code>-traditional</code></dt>
- <dt><code>-traditional-cpp</code></dt>
- <dd><a name="index-traditional_002dcpp"></a>
- <a name="index-traditional"></a>
-
- <p>Try to imitate the behavior of pre-standard C preprocessors, as
- opposed to ISO C preprocessors.
- See <a href="Traditional-Mode.html#Traditional-Mode">Traditional Mode</a>.
- </p>
- <p>Note that GCC does not otherwise attempt to emulate a pre-standard
- C compiler, and these options are only supported with the <samp>-E</samp>
- switch, or when invoking CPP explicitly.
- </p>
- </dd>
- <dt><code>-trigraphs</code></dt>
- <dd><a name="index-trigraphs-1"></a>
- <p>Support ISO C trigraphs.
- These are three-character sequences, all starting with ‘<samp>??</samp>’, that
- are defined by ISO C to stand for single characters. For example,
- ‘<samp>??/</samp>’ stands for ‘<samp>\</samp>’, so ‘<samp>'??/n'</samp>’ is a character
- constant for a newline.
- See <a href="Initial-processing.html#Initial-processing">Initial processing</a>.
- </p>
-
- <p>By default, GCC ignores trigraphs, but in
- standard-conforming modes it converts them. See the <samp>-std</samp> and
- <samp>-ansi</samp> options.
- </p>
- </dd>
- <dt><code>-remap</code></dt>
- <dd><a name="index-remap"></a>
- <p>Enable special code to work around file systems which only permit very
- short file names, such as MS-DOS.
- </p>
- </dd>
- <dt><code>-H</code></dt>
- <dd><a name="index-H"></a>
- <p>Print the name of each header file used, in addition to other normal
- activities. Each name is indented to show how deep in the
- ‘<samp>#include</samp>’ stack it is. Precompiled header files are also
- printed, even if they are found to be invalid; an invalid precompiled
- header file is printed with ‘<samp>...x</samp>’ and a valid one with ‘<samp>...!</samp>’ .
- </p>
- </dd>
- <dt><code>-d<var>letters</var></code></dt>
- <dd><a name="index-d"></a>
- <p>Says to make debugging dumps during compilation as specified by
- <var>letters</var>. The flags documented here are those relevant to the
- preprocessor. Other <var>letters</var> are interpreted
- by the compiler proper, or reserved for future versions of GCC, and so
- are silently ignored. If you specify <var>letters</var> whose behavior
- conflicts, the result is undefined.
- </p>
- <dl compact="compact">
- <dt><code>-dM</code></dt>
- <dd><a name="index-dM"></a>
- <p>Instead of the normal output, generate a list of ‘<samp>#define</samp>’
- directives for all the macros defined during the execution of the
- preprocessor, including predefined macros. This gives you a way of
- finding out what is predefined in your version of the preprocessor.
- Assuming you have no file <samp>foo.h</samp>, the command
- </p>
- <div class="smallexample">
- <pre class="smallexample">touch foo.h; cpp -dM foo.h
- </pre></div>
-
- <p>shows all the predefined macros.
- </p>
-
- </dd>
- <dt><code>-dD</code></dt>
- <dd><a name="index-dD"></a>
- <p>Like <samp>-dM</samp> except in two respects: it does <em>not</em> include the
- predefined macros, and it outputs <em>both</em> the ‘<samp>#define</samp>’
- directives and the result of preprocessing. Both kinds of output go to
- the standard output file.
- </p>
- </dd>
- <dt><code>-dN</code></dt>
- <dd><a name="index-dN"></a>
- <p>Like <samp>-dD</samp>, but emit only the macro names, not their expansions.
- </p>
- </dd>
- <dt><code>-dI</code></dt>
- <dd><a name="index-dI"></a>
- <p>Output ‘<samp>#include</samp>’ directives in addition to the result of
- preprocessing.
- </p>
- </dd>
- <dt><code>-dU</code></dt>
- <dd><a name="index-dU"></a>
- <p>Like <samp>-dD</samp> except that only macros that are expanded, or whose
- definedness is tested in preprocessor directives, are output; the
- output is delayed until the use or test of the macro; and
- ‘<samp>#undef</samp>’ directives are also output for macros tested but
- undefined at the time.
- </p></dd>
- </dl>
-
- </dd>
- <dt><code>-fdebug-cpp</code></dt>
- <dd><a name="index-fdebug_002dcpp"></a>
- <p>This option is only useful for debugging GCC. When used from CPP or with
- <samp>-E</samp>, it dumps debugging information about location maps. Every
- token in the output is preceded by the dump of the map its location
- belongs to.
- </p>
- <p>When used from GCC without <samp>-E</samp>, this option has no effect.
- </p>
-
-
- </dd>
- <dt><code>-I <var>dir</var></code></dt>
- <dt><code>-iquote <var>dir</var></code></dt>
- <dt><code>-isystem <var>dir</var></code></dt>
- <dt><code>-idirafter <var>dir</var></code></dt>
- <dd><a name="index-I"></a>
- <a name="index-iquote"></a>
- <a name="index-isystem"></a>
- <a name="index-idirafter"></a>
- <p>Add the directory <var>dir</var> to the list of directories to be searched
- for header files during preprocessing.
- See <a href="Search-Path.html#Search-Path">Search Path</a>.
- If <var>dir</var> begins with ‘<samp>=</samp>’ or <code>$SYSROOT</code>, then the ‘<samp>=</samp>’
- or <code>$SYSROOT</code> is replaced by the sysroot prefix; see
- <samp>--sysroot</samp> and <samp>-isysroot</samp>.
- </p>
- <p>Directories specified with <samp>-iquote</samp> apply only to the quote
- form of the directive, <code>#include "<var>file</var>"<!-- /@w --></code>.
- Directories specified with <samp>-I</samp>, <samp>-isystem</samp>,
- or <samp>-idirafter</samp> apply to lookup for both the
- <code>#include "<var>file</var>"<!-- /@w --></code> and
- <code>#include <<var>file</var>><!-- /@w --></code> directives.
- </p>
- <p>You can specify any number or combination of these options on the
- command line to search for header files in several directories.
- The lookup order is as follows:
- </p>
- <ol>
- <li> For the quote form of the include directive, the directory of the current
- file is searched first.
-
- </li><li> For the quote form of the include directive, the directories specified
- by <samp>-iquote</samp> options are searched in left-to-right order,
- as they appear on the command line.
-
- </li><li> Directories specified with <samp>-I</samp> options are scanned in
- left-to-right order.
-
- </li><li> Directories specified with <samp>-isystem</samp> options are scanned in
- left-to-right order.
-
- </li><li> Standard system directories are scanned.
-
- </li><li> Directories specified with <samp>-idirafter</samp> options are scanned in
- left-to-right order.
- </li></ol>
-
- <p>You can use <samp>-I</samp> to override a system header
- file, substituting your own version, since these directories are
- searched before the standard system header file directories.
- However, you should
- not use this option to add directories that contain vendor-supplied
- system header files; use <samp>-isystem</samp> for that.
- </p>
- <p>The <samp>-isystem</samp> and <samp>-idirafter</samp> options also mark the directory
- as a system directory, so that it gets the same special treatment that
- is applied to the standard system directories.
- See <a href="System-Headers.html#System-Headers">System Headers</a>.
- </p>
- <p>If a standard system include directory, or a directory specified with
- <samp>-isystem</samp>, is also specified with <samp>-I</samp>, the <samp>-I</samp>
- option is ignored. The directory is still searched but as a
- system directory at its normal position in the system include chain.
- This is to ensure that GCC’s procedure to fix buggy system headers and
- the ordering for the <code>#include_next</code> directive are not inadvertently
- changed.
- If you really need to change the search order for system directories,
- use the <samp>-nostdinc</samp> and/or <samp>-isystem</samp> options.
- See <a href="System-Headers.html#System-Headers">System Headers</a>.
- </p>
- </dd>
- <dt><code>-I-</code></dt>
- <dd><a name="index-I_002d"></a>
- <p>Split the include path.
- This option has been deprecated. Please use <samp>-iquote</samp> instead for
- <samp>-I</samp> directories before the <samp>-I-</samp> and remove the <samp>-I-</samp>
- option.
- </p>
- <p>Any directories specified with <samp>-I</samp>
- options before <samp>-I-</samp> are searched only for headers requested with
- <code>#include "<var>file</var>"<!-- /@w --></code>; they are not searched for
- <code>#include <<var>file</var>><!-- /@w --></code>. If additional directories are
- specified with <samp>-I</samp> options after the <samp>-I-</samp>, those
- directories are searched for all ‘<samp>#include</samp>’ directives.
- </p>
- <p>In addition, <samp>-I-</samp> inhibits the use of the directory of the current
- file directory as the first search directory for <code>#include "<var>file</var>"<!-- /@w --></code>. There is no way to override this effect of <samp>-I-</samp>.
- See <a href="Search-Path.html#Search-Path">Search Path</a>.
- </p>
- </dd>
- <dt><code>-iprefix <var>prefix</var></code></dt>
- <dd><a name="index-iprefix"></a>
- <p>Specify <var>prefix</var> as the prefix for subsequent <samp>-iwithprefix</samp>
- options. If the prefix represents a directory, you should include the
- final ‘<samp>/</samp>’.
- </p>
- </dd>
- <dt><code>-iwithprefix <var>dir</var></code></dt>
- <dt><code>-iwithprefixbefore <var>dir</var></code></dt>
- <dd><a name="index-iwithprefix"></a>
- <a name="index-iwithprefixbefore"></a>
- <p>Append <var>dir</var> to the prefix specified previously with
- <samp>-iprefix</samp>, and add the resulting directory to the include search
- path. <samp>-iwithprefixbefore</samp> puts it in the same place <samp>-I</samp>
- would; <samp>-iwithprefix</samp> puts it where <samp>-idirafter</samp> would.
- </p>
- </dd>
- <dt><code>-isysroot <var>dir</var></code></dt>
- <dd><a name="index-isysroot"></a>
- <p>This option is like the <samp>--sysroot</samp> option, but applies only to
- header files (except for Darwin targets, where it applies to both header
- files and libraries). See the <samp>--sysroot</samp> option for more
- information.
- </p>
- </dd>
- <dt><code>-imultilib <var>dir</var></code></dt>
- <dd><a name="index-imultilib"></a>
- <p>Use <var>dir</var> as a subdirectory of the directory containing
- target-specific C++ headers.
- </p>
- </dd>
- <dt><code>-nostdinc</code></dt>
- <dd><a name="index-nostdinc"></a>
- <p>Do not search the standard system directories for header files.
- Only the directories explicitly specified with <samp>-I</samp>,
- <samp>-iquote</samp>, <samp>-isystem</samp>, and/or <samp>-idirafter</samp>
- options (and the directory of the current file, if appropriate)
- are searched.
- </p>
- </dd>
- <dt><code>-nostdinc++</code></dt>
- <dd><a name="index-nostdinc_002b_002b"></a>
- <p>Do not search for header files in the C++-specific standard directories,
- but do still search the other standard directories. (This option is
- used when building the C++ library.)
- </p>
-
-
-
- </dd>
- <dt><code>-Wcomment</code></dt>
- <dt><code>-Wcomments</code></dt>
- <dd><a name="index-Wcomment"></a>
- <a name="index-Wcomments"></a>
- <p>Warn whenever a comment-start sequence ‘<samp>/*</samp>’ appears in a ‘<samp>/*</samp>’
- comment, or whenever a backslash-newline appears in a ‘<samp>//</samp>’ comment.
- This warning is enabled by <samp>-Wall</samp>.
- </p>
- </dd>
- <dt><code>-Wtrigraphs</code></dt>
- <dd><a name="index-Wtrigraphs"></a>
- <a name="Wtrigraphs"></a><p>Warn if any trigraphs are encountered that might change the meaning of
- the program. Trigraphs within comments are not warned about,
- except those that would form escaped newlines.
- </p>
- <p>This option is implied by <samp>-Wall</samp>. If <samp>-Wall</samp> is not
- given, this option is still enabled unless trigraphs are enabled. To
- get trigraph conversion without warnings, but get the other
- <samp>-Wall</samp> warnings, use ‘<samp>-trigraphs -Wall -Wno-trigraphs</samp>’.
- </p>
- </dd>
- <dt><code>-Wundef</code></dt>
- <dd><a name="index-Wundef"></a>
- <a name="index-Wno_002dundef"></a>
- <p>Warn if an undefined identifier is evaluated in an <code>#if</code> directive.
- Such identifiers are replaced with zero.
- </p>
- </dd>
- <dt><code>-Wexpansion-to-defined</code></dt>
- <dd><a name="index-Wexpansion_002dto_002ddefined"></a>
- <p>Warn whenever ‘<samp>defined</samp>’ is encountered in the expansion of a macro
- (including the case where the macro is expanded by an ‘<samp>#if</samp>’ directive).
- Such usage is not portable.
- This warning is also enabled by <samp>-Wpedantic</samp> and <samp>-Wextra</samp>.
- </p>
- </dd>
- <dt><code>-Wunused-macros</code></dt>
- <dd><a name="index-Wunused_002dmacros"></a>
- <p>Warn about macros defined in the main file that are unused. A macro
- is <em>used</em> if it is expanded or tested for existence at least once.
- The preprocessor also warns if the macro has not been used at the
- time it is redefined or undefined.
- </p>
- <p>Built-in macros, macros defined on the command line, and macros
- defined in include files are not warned about.
- </p>
- <p><em>Note:</em> If a macro is actually used, but only used in skipped
- conditional blocks, then the preprocessor reports it as unused. To avoid the
- warning in such a case, you might improve the scope of the macro’s
- definition by, for example, moving it into the first skipped block.
- Alternatively, you could provide a dummy use with something like:
- </p>
- <div class="smallexample">
- <pre class="smallexample">#if defined the_macro_causing_the_warning
- #endif
- </pre></div>
-
- </dd>
- <dt><code>-Wno-endif-labels</code></dt>
- <dd><a name="index-Wno_002dendif_002dlabels"></a>
- <a name="index-Wendif_002dlabels"></a>
- <p>Do not warn whenever an <code>#else</code> or an <code>#endif</code> are followed by text.
- This sometimes happens in older programs with code of the form
- </p>
- <div class="smallexample">
- <pre class="smallexample">#if FOO
- …
- #else FOO
- …
- #endif FOO
- </pre></div>
-
- <p>The second and third <code>FOO</code> should be in comments.
- This warning is on by default.
- </p></dd>
- </dl>
-
- <hr>
- <div class="header">
- <p>
- Next: <a href="Environment-Variables.html#Environment-Variables" accesskey="n" rel="next">Environment Variables</a>, Previous: <a href="Implementation-Details.html#Implementation-Details" accesskey="p" rel="prev">Implementation Details</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html#Index-of-Directives" title="Index" rel="index">Index</a>]</p>
- </div>
-
-
-
- </body>
- </html>
|