| <html lang="en"> | |
| <head> | |
| <title>Preprocessor Options - 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.13"> | |
| <link title="Top" rel="start" href="index.html#Top"> | |
| <link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC"> | |
| <link rel="prev" href="Optimize-Options.html#Optimize-Options" title="Optimize Options"> | |
| <link rel="next" href="Assembler-Options.html#Assembler-Options" title="Assembler Options"> | |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> | |
| <!-- | |
| Copyright (C) 1988-2013 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; with the | |
| Invariant Sections being ``Funding Free Software'', the Front-Cover | |
| Texts being (a) (see below), and with the Back-Cover Texts being (b) | |
| (see below). A copy of the license is included in the section entitled | |
| ``GNU Free Documentation License''. | |
| (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.--> | |
| <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 } | |
| span.sc { font-variant:small-caps } | |
| span.roman { font-family:serif; font-weight:normal; } | |
| span.sansserif { font-family:sans-serif; font-weight:normal; } | |
| --></style> | |
| </head> | |
| <body> | |
| <div class="node"> | |
| <a name="Preprocessor-Options"></a> | |
| <p> | |
| Next: <a rel="next" accesskey="n" href="Assembler-Options.html#Assembler-Options">Assembler Options</a>, | |
| Previous: <a rel="previous" accesskey="p" href="Optimize-Options.html#Optimize-Options">Optimize Options</a>, | |
| Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a> | |
| <hr> | |
| </div> | |
| <h3 class="section">3.11 Options Controlling the Preprocessor</h3> | |
| <p><a name="index-preprocessor-options-936"></a><a name="index-options_002c-preprocessor-937"></a> | |
| These options control the C preprocessor, which is run on each C source | |
| file before actual compilation. | |
| <p>If you use the <samp><span class="option">-E</span></samp> option, nothing is done except preprocessing. | |
| Some of these options make sense only together with <samp><span class="option">-E</span></samp> because | |
| they cause the preprocessor output to be unsuitable for actual | |
| compilation. | |
| <dl> | |
| <dt><code>-Wp,</code><var>option</var><dd><a name="index-Wp-938"></a>You can use <samp><span class="option">-Wp,</span><var>option</var></samp> to bypass the compiler driver | |
| and pass <var>option</var> directly through to the preprocessor. If | |
| <var>option</var> contains commas, it is split into multiple options at the | |
| commas. However, many options are modified, translated or interpreted | |
| by the compiler driver before being passed to the preprocessor, and | |
| <samp><span class="option">-Wp</span></samp> forcibly bypasses this phase. The preprocessor's direct | |
| interface is undocumented and subject to change, so whenever possible | |
| you should avoid using <samp><span class="option">-Wp</span></samp> and let the driver handle the | |
| options instead. | |
| <br><dt><code>-Xpreprocessor </code><var>option</var><dd><a name="index-Xpreprocessor-939"></a>Pass <var>option</var> as an option to the preprocessor. You can use this to | |
| supply system-specific preprocessor options that GCC does not | |
| recognize. | |
| <p>If you want to pass an option that takes an argument, you must use | |
| <samp><span class="option">-Xpreprocessor</span></samp> twice, once for the option and once for the argument. | |
| <br><dt><code>-no-integrated-cpp</code><dd><a name="index-no_002dintegrated_002dcpp-940"></a>Perform preprocessing as a separate pass before compilation. | |
| By default, GCC performs preprocessing as an integrated part of | |
| input tokenization and parsing. | |
| If this option is provided, the appropriate language front end | |
| (<samp><span class="command">cc1</span></samp>, <samp><span class="command">cc1plus</span></samp>, or <samp><span class="command">cc1obj</span></samp> for C, C++, | |
| and Objective-C, respectively) is instead invoked twice, | |
| once for preprocessing only and once for actual compilation | |
| of the preprocessed input. | |
| This option may be useful in conjunction with the <samp><span class="option">-B</span></samp> or | |
| <samp><span class="option">-wrapper</span></samp> options to specify an alternate preprocessor or | |
| perform additional processing of the program source between | |
| normal preprocessing and compilation. | |
| </dl> | |
| <!-- Copyright (C) 1999-2013 Free Software Foundation, Inc. --> | |
| <!-- This is part of the CPP and GCC manuals. --> | |
| <!-- For copying conditions, see the file gcc.texi. --> | |
| <!-- --> | |
| <!-- Options affecting the preprocessor --> | |
| <!-- --> | |
| <!-- If this file is included with the flag ``cppmanual'' set, it is --> | |
| <!-- formatted for inclusion in the CPP manual; otherwise the main GCC manual. --> | |
| <dl> | |
| <dt><code>-D </code><var>name</var><dd><a name="index-D-941"></a>Predefine <var>name</var> as a macro, with definition <code>1</code>. | |
| <br><dt><code>-D </code><var>name</var><code>=</code><var>definition</var><dd>The contents of <var>definition</var> are tokenized and processed as if | |
| they appeared during translation phase three in a ‘<samp><span class="samp">#define</span></samp>’ | |
| directive. In particular, the definition will be truncated by | |
| embedded newline characters. | |
| <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>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 will need | |
| to quote the option. With <samp><span class="command">sh</span></samp> and <samp><span class="command">csh</span></samp>, | |
| <samp><span class="option">-D'</span><var>name</var><span class="option">(</span><var>args<small class="dots">...</small></var><span class="option">)=</span><var>definition</var><span class="option">'</span></samp> works. | |
| <p><samp><span class="option">-D</span></samp> and <samp><span class="option">-U</span></samp> options are processed in the order they | |
| are given on the command line. All <samp><span class="option">-imacros </span><var>file</var></samp> and | |
| <samp><span class="option">-include </span><var>file</var></samp> options are processed after all | |
| <samp><span class="option">-D</span></samp> and <samp><span class="option">-U</span></samp> options. | |
| <br><dt><code>-U </code><var>name</var><dd><a name="index-U-942"></a>Cancel any previous definition of <var>name</var>, either built in or | |
| provided with a <samp><span class="option">-D</span></samp> option. | |
| <br><dt><code>-undef</code><dd><a name="index-undef-943"></a>Do not predefine any system-specific or GCC-specific macros. The | |
| standard predefined macros remain defined. | |
| <br><dt><code>-I </code><var>dir</var><dd><a name="index-I-944"></a>Add the directory <var>dir</var> to the list of directories to be searched | |
| for header files. | |
| Directories named by <samp><span class="option">-I</span></samp> are searched before the standard | |
| system include directories. If the directory <var>dir</var> is a standard | |
| system include directory, the option is ignored to ensure that the | |
| default search order for system directories and the special treatment | |
| of system headers are not defeated | |
| . | |
| If <var>dir</var> begins with <code>=</code>, then the <code>=</code> will be replaced | |
| by the sysroot prefix; see <samp><span class="option">--sysroot</span></samp> and <samp><span class="option">-isysroot</span></samp>. | |
| <br><dt><code>-o </code><var>file</var><dd><a name="index-o-945"></a>Write output to <var>file</var>. This is the same as specifying <var>file</var> | |
| as the second non-option argument to <samp><span class="command">cpp</span></samp>. <samp><span class="command">gcc</span></samp> has a | |
| different interpretation of a second non-option argument, so you must | |
| use <samp><span class="option">-o</span></samp> to specify the output file. | |
| <br><dt><code>-Wall</code><dd><a name="index-Wall-946"></a>Turns on all optional warnings which are desirable for normal code. | |
| At present this is <samp><span class="option">-Wcomment</span></samp>, <samp><span class="option">-Wtrigraphs</span></samp>, | |
| <samp><span class="option">-Wmultichar</span></samp> and a warning about integer promotion causing a | |
| change of sign in <code>#if</code> expressions. Note that many of the | |
| preprocessor's warnings are on by default and have no options to | |
| control them. | |
| <br><dt><code>-Wcomment</code><dt><code>-Wcomments</code><dd><a name="index-Wcomment-947"></a><a name="index-Wcomments-948"></a>Warn whenever a comment-start sequence ‘<samp><span class="samp">/*</span></samp>’ appears in a ‘<samp><span class="samp">/*</span></samp>’ | |
| comment, or whenever a backslash-newline appears in a ‘<samp><span class="samp">//</span></samp>’ comment. | |
| (Both forms have the same effect.) | |
| <br><dt><code>-Wtrigraphs</code><dd><a name="index-Wtrigraphs-949"></a><a name="Wtrigraphs"></a>Most trigraphs in comments cannot affect the meaning of the program. | |
| However, a trigraph that would form an escaped newline (‘<samp><span class="samp">??/</span></samp>’ at | |
| the end of a line) can, by changing where the comment begins or ends. | |
| Therefore, only trigraphs that would form escaped newlines produce | |
| warnings inside a comment. | |
| <p>This option is implied by <samp><span class="option">-Wall</span></samp>. If <samp><span class="option">-Wall</span></samp> is not | |
| given, this option is still enabled unless trigraphs are enabled. To | |
| get trigraph conversion without warnings, but get the other | |
| <samp><span class="option">-Wall</span></samp> warnings, use ‘<samp><span class="samp">-trigraphs -Wall -Wno-trigraphs</span></samp>’. | |
| <br><dt><code>-Wtraditional</code><dd><a name="index-Wtraditional-950"></a>Warn about certain constructs that behave differently in traditional and | |
| ISO C. Also warn about ISO C constructs that have no traditional C | |
| equivalent, and problematic constructs which should be avoided. | |
| <br><dt><code>-Wundef</code><dd><a name="index-Wundef-951"></a>Warn whenever an identifier which is not a macro is encountered in an | |
| ‘<samp><span class="samp">#if</span></samp>’ directive, outside of ‘<samp><span class="samp">defined</span></samp>’. Such identifiers are | |
| replaced with zero. | |
| <br><dt><code>-Wunused-macros</code><dd><a name="index-Wunused_002dmacros-952"></a>Warn about macros defined in the main file that are unused. A macro | |
| is <dfn>used</dfn> if it is expanded or tested for existence at least once. | |
| The preprocessor will also warn if the macro has not been used at the | |
| time it is redefined or undefined. | |
| <p>Built-in macros, macros defined on the command line, and macros | |
| defined in include files are not warned about. | |
| <p><em>Note:</em> If a macro is actually used, but only used in skipped | |
| conditional blocks, then CPP will report 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: | |
| <pre class="smallexample"> #if defined the_macro_causing_the_warning | |
| #endif | |
| </pre> | |
| <br><dt><code>-Wendif-labels</code><dd><a name="index-Wendif_002dlabels-953"></a>Warn whenever an ‘<samp><span class="samp">#else</span></samp>’ or an ‘<samp><span class="samp">#endif</span></samp>’ are followed by text. | |
| This usually happens in code of the form | |
| <pre class="smallexample"> #if FOO | |
| ... | |
| #else FOO | |
| ... | |
| #endif FOO | |
| </pre> | |
| <p class="noindent">The second and third <code>FOO</code> should be in comments, but often are not | |
| in older programs. This warning is on by default. | |
| <br><dt><code>-Werror</code><dd><a name="index-Werror-954"></a>Make all warnings into hard errors. Source code which triggers warnings | |
| will be rejected. | |
| <br><dt><code>-Wsystem-headers</code><dd><a name="index-Wsystem_002dheaders-955"></a>Issue warnings for code in system headers. These are normally unhelpful | |
| in finding bugs in your own code, therefore suppressed. If you are | |
| responsible for the system library, you may want to see them. | |
| <br><dt><code>-w</code><dd><a name="index-w-956"></a>Suppress all warnings, including those which GNU CPP issues by default. | |
| <br><dt><code>-pedantic</code><dd><a name="index-pedantic-957"></a>Issue all the mandatory diagnostics listed in the C standard. Some of | |
| them are left out by default, since they trigger frequently on harmless | |
| code. | |
| <br><dt><code>-pedantic-errors</code><dd><a name="index-pedantic_002derrors-958"></a>Issue all the mandatory diagnostics, and make all mandatory diagnostics | |
| into errors. This includes mandatory diagnostics that GCC issues | |
| without ‘<samp><span class="samp">-pedantic</span></samp>’ but treats as warnings. | |
| <br><dt><code>-M</code><dd><a name="index-M-959"></a><a name="index-g_t_0040command_007bmake_007d-960"></a><a name="index-dependencies_002c-_0040command_007bmake_007d-961"></a>Instead of outputting the result of preprocessing, output a rule | |
| suitable for <samp><span class="command">make</span></samp> describing the dependencies of the main | |
| source file. The preprocessor outputs one <samp><span class="command">make</span></samp> 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><span class="option">-include</span></samp> or | |
| <samp><span class="option">-imacros</span></samp> command line options. | |
| <p>Unless specified explicitly (with <samp><span class="option">-MT</span></samp> or <samp><span class="option">-MQ</span></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><span class="samp">\</span></samp>’-newline. The rule has no | |
| commands. | |
| <p>This option does not suppress the preprocessor's debug output, such as | |
| <samp><span class="option">-dM</span></samp>. To avoid mixing such debug output with the dependency | |
| rules you should explicitly specify the dependency output file with | |
| <samp><span class="option">-MF</span></samp>, or use an environment variable like | |
| <samp><span class="env">DEPENDENCIES_OUTPUT</span></samp> (see <a href="Environment-Variables.html#Environment-Variables">Environment Variables</a>). Debug output | |
| will still be sent to the regular output stream as normal. | |
| <p>Passing <samp><span class="option">-M</span></samp> to the driver implies <samp><span class="option">-E</span></samp>, and suppresses | |
| warnings with an implicit <samp><span class="option">-w</span></samp>. | |
| <br><dt><code>-MM</code><dd><a name="index-MM-962"></a>Like <samp><span class="option">-M</span></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>This implies that the choice of angle brackets or double quotes in an | |
| ‘<samp><span class="samp">#include</span></samp>’ directive does not in itself determine whether that | |
| header will appear in <samp><span class="option">-MM</span></samp> dependency output. This is a | |
| slight change in semantics from GCC versions 3.0 and earlier. | |
| <p><a name="dashMF"></a><br><dt><code>-MF </code><var>file</var><dd><a name="index-MF-963"></a>When used with <samp><span class="option">-M</span></samp> or <samp><span class="option">-MM</span></samp>, specifies a | |
| file to write the dependencies to. If no <samp><span class="option">-MF</span></samp> switch is given | |
| the preprocessor sends the rules to the same place it would have sent | |
| preprocessed output. | |
| <p>When used with the driver options <samp><span class="option">-MD</span></samp> or <samp><span class="option">-MMD</span></samp>, | |
| <samp><span class="option">-MF</span></samp> overrides the default dependency output file. | |
| <br><dt><code>-MG</code><dd><a name="index-MG-964"></a>In conjunction with an option such as <samp><span class="option">-M</span></samp> requesting | |
| dependency generation, <samp><span class="option">-MG</span></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><span class="option">-MG</span></samp> | |
| also suppresses preprocessed output, as a missing header file renders | |
| this useless. | |
| <p>This feature is used in automatic updating of makefiles. | |
| <br><dt><code>-MP</code><dd><a name="index-MP-965"></a>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 <samp><span class="command">make</span></samp> gives if you remove header | |
| files without updating the <samp><span class="file">Makefile</span></samp> to match. | |
| <p>This is typical output: | |
| <pre class="smallexample"> test.o: test.c test.h | |
| test.h: | |
| </pre> | |
| <br><dt><code>-MT </code><var>target</var><dd><a name="index-MT-966"></a> | |
| 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><span class="samp">.c</span></samp>’, and | |
| appends the platform's usual object suffix. The result is the target. | |
| <p>An <samp><span class="option">-MT</span></samp> option will set the target to be exactly the string you | |
| specify. If you want multiple targets, you can specify them as a single | |
| argument to <samp><span class="option">-MT</span></samp>, or use multiple <samp><span class="option">-MT</span></samp> options. | |
| <p>For example, <samp><span class="option">-MT '$(objpfx)foo.o'<!-- /@w --></span></samp> might give | |
| <pre class="smallexample"> $(objpfx)foo.o: foo.c | |
| </pre> | |
| <br><dt><code>-MQ </code><var>target</var><dd><a name="index-MQ-967"></a> | |
| Same as <samp><span class="option">-MT</span></samp>, but it quotes any characters which are special to | |
| Make. <samp><span class="option">-MQ '$(objpfx)foo.o'<!-- /@w --></span></samp> gives | |
| <pre class="smallexample"> $$(objpfx)foo.o: foo.c | |
| </pre> | |
| <p>The default target is automatically quoted, as if it were given with | |
| <samp><span class="option">-MQ</span></samp>. | |
| <br><dt><code>-MD</code><dd><a name="index-MD-968"></a><samp><span class="option">-MD</span></samp> is equivalent to <samp><span class="option">-M -MF </span><var>file</var></samp>, except that | |
| <samp><span class="option">-E</span></samp> is not implied. The driver determines <var>file</var> based on | |
| whether an <samp><span class="option">-o</span></samp> option is given. If it is, the driver uses its | |
| argument but with a suffix of <samp><span class="file">.d</span></samp>, otherwise it takes the name | |
| of the input file, removes any directory components and suffix, and | |
| applies a <samp><span class="file">.d</span></samp> suffix. | |
| <p>If <samp><span class="option">-MD</span></samp> is used in conjunction with <samp><span class="option">-E</span></samp>, any | |
| <samp><span class="option">-o</span></samp> switch is understood to specify the dependency output file | |
| (see <a href="dashMF.html#dashMF">-MF</a>), but if used without <samp><span class="option">-E</span></samp>, each <samp><span class="option">-o</span></samp> | |
| is understood to specify a target object file. | |
| <p>Since <samp><span class="option">-E</span></samp> is not implied, <samp><span class="option">-MD</span></samp> can be used to generate | |
| a dependency output file as a side-effect of the compilation process. | |
| <br><dt><code>-MMD</code><dd><a name="index-MMD-969"></a>Like <samp><span class="option">-MD</span></samp> except mention only user header files, not system | |
| header files. | |
| <br><dt><code>-fpch-deps</code><dd><a name="index-fpch_002ddeps-970"></a>When using precompiled headers (see <a href="Precompiled-Headers.html#Precompiled-Headers">Precompiled Headers</a>), this flag | |
| will cause the dependency-output flags to also list the files from the | |
| precompiled header's dependencies. If not specified only the | |
| precompiled header would be listed and not the files that were used to | |
| create it because those files are not consulted when a precompiled | |
| header is used. | |
| <br><dt><code>-fpch-preprocess</code><dd><a name="index-fpch_002dpreprocess-971"></a>This option allows use of a precompiled header (see <a href="Precompiled-Headers.html#Precompiled-Headers">Precompiled Headers</a>) together with <samp><span class="option">-E</span></samp>. It inserts a special <code>#pragma</code>, | |
| <code>#pragma GCC pch_preprocess "</code><var>filename</var><code>"</code> in the output to mark | |
| the place where the precompiled header was found, and its <var>filename</var>. | |
| When <samp><span class="option">-fpreprocessed</span></samp> is in use, GCC recognizes this <code>#pragma</code> | |
| and loads the PCH. | |
| <p>This option is off by default, because the resulting preprocessed output | |
| is only really suitable as input to GCC. It is switched on by | |
| <samp><span class="option">-save-temps</span></samp>. | |
| <p>You should not write this <code>#pragma</code> in your own code, but it is | |
| safe to edit the filename if the PCH file is available in a different | |
| location. The filename may be absolute or it may be relative to GCC's | |
| current directory. | |
| <br><dt><code>-x c</code><dt><code>-x c++</code><dt><code>-x objective-c</code><dt><code>-x assembler-with-cpp</code><dd><a name="index-x-972"></a>Specify the source language: C, C++, Objective-C, or assembly. This has | |
| nothing to do with standards conformance or extensions; it merely | |
| selects 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><span class="samp">.c</span></samp>’, ‘<samp><span class="samp">.cc</span></samp>’, ‘<samp><span class="samp">.m</span></samp>’, or ‘<samp><span class="samp">.S</span></samp>’. Some other common | |
| extensions for C++ and assembly are also recognized. If cpp does not | |
| recognize the extension, it will treat the file as C; this is the most | |
| generic mode. | |
| <p><em>Note:</em> Previous versions of cpp accepted a <samp><span class="option">-lang</span></samp> option | |
| which selected both the language and the standards conformance level. | |
| This option has been removed, because it conflicts with the <samp><span class="option">-l</span></samp> | |
| option. | |
| <br><dt><code>-std=</code><var>standard</var><dt><code>-ansi</code><dd><a name="index-ansi-973"></a><a name="index-std_003d-974"></a>Specify the standard to which the code should conform. Currently CPP | |
| knows about C and C++ standards; others may be added in the future. | |
| <p><var>standard</var> | |
| may be one of: | |
| <dl> | |
| <dt><code>c90</code><dt><code>c89</code><dt><code>iso9899:1990</code><dd>The ISO C standard from 1990. ‘<samp><span class="samp">c90</span></samp>’ is the customary shorthand for | |
| this version of the standard. | |
| <p>The <samp><span class="option">-ansi</span></samp> option is equivalent to <samp><span class="option">-std=c90</span></samp>. | |
| <br><dt><code>iso9899:199409</code><dd>The 1990 C standard, as amended in 1994. | |
| <br><dt><code>iso9899:1999</code><dt><code>c99</code><dt><code>iso9899:199x</code><dt><code>c9x</code><dd>The revised ISO C standard, published in December 1999. Before | |
| publication, this was known as C9X. | |
| <br><dt><code>iso9899:2011</code><dt><code>c11</code><dt><code>c1x</code><dd>The revised ISO C standard, published in December 2011. Before | |
| publication, this was known as C1X. | |
| <br><dt><code>gnu90</code><dt><code>gnu89</code><dd>The 1990 C standard plus GNU extensions. This is the default. | |
| <br><dt><code>gnu99</code><dt><code>gnu9x</code><dd>The 1999 C standard plus GNU extensions. | |
| <br><dt><code>gnu11</code><dt><code>gnu1x</code><dd>The 2011 C standard plus GNU extensions. | |
| <br><dt><code>c++98</code><dd>The 1998 ISO C++ standard plus amendments. | |
| <br><dt><code>gnu++98</code><dd>The same as <samp><span class="option">-std=c++98</span></samp> plus GNU extensions. This is the | |
| default for C++ code. | |
| </dl> | |
| <br><dt><code>-I-</code><dd><a name="index-I_002d-975"></a>Split the include path. Any directories specified with <samp><span class="option">-I</span></samp> | |
| options before <samp><span class="option">-I-</span></samp> are searched only for headers requested with | |
| <code>#include "</code><var>file</var><code>"<!-- /@w --></code>; they are not searched for | |
| <code>#include <</code><var>file</var><code>><!-- /@w --></code>. If additional directories are | |
| specified with <samp><span class="option">-I</span></samp> options after the <samp><span class="option">-I-</span></samp>, those | |
| directories are searched for all ‘<samp><span class="samp">#include</span></samp>’ directives. | |
| <p>In addition, <samp><span class="option">-I-</span></samp> inhibits the use of the directory of the current | |
| file directory as the first search directory for <code>#include "</code><var>file</var><code>"<!-- /@w --></code>. | |
| This option has been deprecated. | |
| <br><dt><code>-nostdinc</code><dd><a name="index-nostdinc-976"></a>Do not search the standard system directories for header files. | |
| Only the directories you have specified with <samp><span class="option">-I</span></samp> options | |
| (and the directory of the current file, if appropriate) are searched. | |
| <br><dt><code>-nostdinc++</code><dd><a name="index-nostdinc_002b_002b-977"></a>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.) | |
| <br><dt><code>-include </code><var>file</var><dd><a name="index-include-978"></a>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>If multiple <samp><span class="option">-include</span></samp> options are given, the files are included | |
| in the order they appear on the command line. | |
| <br><dt><code>-imacros </code><var>file</var><dd><a name="index-imacros-979"></a>Exactly like <samp><span class="option">-include</span></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>All files specified by <samp><span class="option">-imacros</span></samp> are processed before all files | |
| specified by <samp><span class="option">-include</span></samp>. | |
| <br><dt><code>-idirafter </code><var>dir</var><dd><a name="index-idirafter-980"></a>Search <var>dir</var> for header files, but do it <em>after</em> all | |
| directories specified with <samp><span class="option">-I</span></samp> and the standard system directories | |
| have been exhausted. <var>dir</var> is treated as a system include directory. | |
| If <var>dir</var> begins with <code>=</code>, then the <code>=</code> will be replaced | |
| by the sysroot prefix; see <samp><span class="option">--sysroot</span></samp> and <samp><span class="option">-isysroot</span></samp>. | |
| <br><dt><code>-iprefix </code><var>prefix</var><dd><a name="index-iprefix-981"></a>Specify <var>prefix</var> as the prefix for subsequent <samp><span class="option">-iwithprefix</span></samp> | |
| options. If the prefix represents a directory, you should include the | |
| final ‘<samp><span class="samp">/</span></samp>’. | |
| <br><dt><code>-iwithprefix </code><var>dir</var><dt><code>-iwithprefixbefore </code><var>dir</var><dd><a name="index-iwithprefix-982"></a><a name="index-iwithprefixbefore-983"></a>Append <var>dir</var> to the prefix specified previously with | |
| <samp><span class="option">-iprefix</span></samp>, and add the resulting directory to the include search | |
| path. <samp><span class="option">-iwithprefixbefore</span></samp> puts it in the same place <samp><span class="option">-I</span></samp> | |
| would; <samp><span class="option">-iwithprefix</span></samp> puts it where <samp><span class="option">-idirafter</span></samp> would. | |
| <br><dt><code>-isysroot </code><var>dir</var><dd><a name="index-isysroot-984"></a>This option is like the <samp><span class="option">--sysroot</span></samp> option, but applies only to | |
| header files (except for Darwin targets, where it applies to both header | |
| files and libraries). See the <samp><span class="option">--sysroot</span></samp> option for more | |
| information. | |
| <br><dt><code>-imultilib </code><var>dir</var><dd><a name="index-imultilib-985"></a>Use <var>dir</var> as a subdirectory of the directory containing | |
| target-specific C++ headers. | |
| <br><dt><code>-isystem </code><var>dir</var><dd><a name="index-isystem-986"></a>Search <var>dir</var> for header files, after all directories specified by | |
| <samp><span class="option">-I</span></samp> but before the standard system directories. Mark it | |
| as a system directory, so that it gets the same special treatment as | |
| is applied to the standard system directories. | |
| If <var>dir</var> begins with <code>=</code>, then the <code>=</code> will be replaced | |
| by the sysroot prefix; see <samp><span class="option">--sysroot</span></samp> and <samp><span class="option">-isysroot</span></samp>. | |
| <br><dt><code>-iquote </code><var>dir</var><dd><a name="index-iquote-987"></a>Search <var>dir</var> only for header files requested with | |
| <code>#include "</code><var>file</var><code>"<!-- /@w --></code>; they are not searched for | |
| <code>#include <</code><var>file</var><code>><!-- /@w --></code>, before all directories specified by | |
| <samp><span class="option">-I</span></samp> and before the standard system directories. | |
| If <var>dir</var> begins with <code>=</code>, then the <code>=</code> will be replaced | |
| by the sysroot prefix; see <samp><span class="option">--sysroot</span></samp> and <samp><span class="option">-isysroot</span></samp>. | |
| <br><dt><code>-fdirectives-only</code><dd><a name="index-fdirectives_002donly-988"></a>When preprocessing, handle directives, but do not expand macros. | |
| <p>The option's behavior depends on the <samp><span class="option">-E</span></samp> and <samp><span class="option">-fpreprocessed</span></samp> | |
| options. | |
| <p>With <samp><span class="option">-E</span></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><span class="option">-dD</span></samp> option is | |
| implicitly enabled. | |
| <p>With <samp><span class="option">-fpreprocessed</span></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>With both <samp><span class="option">-E</span></samp> and <samp><span class="option">-fpreprocessed</span></samp>, the rules for | |
| <samp><span class="option">-fpreprocessed</span></samp> take precedence. This enables full preprocessing of | |
| files previously preprocessed with <code>-E -fdirectives-only</code>. | |
| <br><dt><code>-fdollars-in-identifiers</code><dd><a name="index-fdollars_002din_002didentifiers-989"></a><a name="fdollars_002din_002didentifiers"></a>Accept ‘<samp><span class="samp">$</span></samp>’ in identifiers. | |
| <br><dt><code>-fextended-identifiers</code><dd><a name="index-fextended_002didentifiers-990"></a>Accept universal character names in identifiers. This option is | |
| experimental; in a future version of GCC, it will be enabled by | |
| default for C99 and C++. | |
| <br><dt><code>-fno-canonical-system-headers</code><dd><a name="index-fno_002dcanonical_002dsystem_002dheaders-991"></a>When preprocessing, do not shorten system header paths with canonicalization. | |
| <br><dt><code>-fpreprocessed</code><dd><a name="index-fpreprocessed-992"></a>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><span class="option">-C</span></samp> to the compiler without | |
| problems. In this mode the integrated preprocessor is little more than | |
| a tokenizer for the front ends. | |
| <p><samp><span class="option">-fpreprocessed</span></samp> is implicit if the input file has one of the | |
| extensions ‘<samp><span class="samp">.i</span></samp>’, ‘<samp><span class="samp">.ii</span></samp>’ or ‘<samp><span class="samp">.mi</span></samp>’. These are the | |
| extensions that GCC uses for preprocessed files created by | |
| <samp><span class="option">-save-temps</span></samp>. | |
| <br><dt><code>-ftabstop=</code><var>width</var><dd><a name="index-ftabstop-993"></a>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. | |
| <br><dt><code>-fdebug-cpp</code><dd><a name="index-fdebug_002dcpp-994"></a>This option is only useful for debugging GCC. When used with | |
| <samp><span class="option">-E</span></samp>, dumps debugging information about location maps. Every | |
| token in the output is preceded by the dump of the map its location | |
| belongs to. The dump of the map holding the location of a token would | |
| be: | |
| <pre class="smallexample"> {‘<samp><span class="samp">P</span></samp>’:<samp><span class="file">/file/path</span></samp>;‘<samp><span class="samp">F</span></samp>’:<samp><span class="file">/includer/path</span></samp>;‘<samp><span class="samp">L</span></samp>’:<var>line_num</var>;‘<samp><span class="samp">C</span></samp>’:<var>col_num</var>;‘<samp><span class="samp">S</span></samp>’:<var>system_header_p</var>;‘<samp><span class="samp">M</span></samp>’:<var>map_address</var>;‘<samp><span class="samp">E</span></samp>’:<var>macro_expansion_p</var>,‘<samp><span class="samp">loc</span></samp>’:<var>location</var>} | |
| </pre> | |
| <p>When used without <samp><span class="option">-E</span></samp>, this option has no effect. | |
| <br><dt><code>-ftrack-macro-expansion</code><span class="roman">[</span><code>=</code><var>level</var><span class="roman">]</span><dd><a name="index-ftrack_002dmacro_002dexpansion-995"></a>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><span class="samp">0</span></samp>’ of <var>level</var> de-activates | |
| this option just as if no <samp><span class="option">-ftrack-macro-expansion</span></samp> was present | |
| on the command line. Value ‘<samp><span class="samp">1</span></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><span class="samp">2</span></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><span class="samp">2</span></samp>’. | |
| <p>Note that -ftrack-macro-expansion=2 is activated by default. | |
| <br><dt><code>-fexec-charset=</code><var>charset</var><dd><a name="index-fexec_002dcharset-996"></a><a name="index-character-set_002c-execution-997"></a>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. | |
| <br><dt><code>-fwide-exec-charset=</code><var>charset</var><dd><a name="index-fwide_002dexec_002dcharset-998"></a><a name="index-character-set_002c-wide-execution-999"></a>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><span class="option">-fexec-charset</span></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>. | |
| <br><dt><code>-finput-charset=</code><var>charset</var><dd><a name="index-finput_002dcharset-1000"></a><a name="index-character-set_002c-input-1001"></a>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. | |
| <br><dt><code>-fworking-directory</code><dd><a name="index-fworking_002ddirectory-1002"></a><a name="index-fno_002dworking_002ddirectory-1003"></a>Enable generation of linemarkers in the preprocessor output that will | |
| let the compiler know the current working directory at the time of | |
| preprocessing. When this option is enabled, the preprocessor will | |
| emit, after the initial linemarker, a second linemarker with the | |
| current working directory followed by two slashes. GCC will use 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><span class="option">-fno-working-directory</span></samp>. If the <samp><span class="option">-P</span></samp> flag is | |
| present in the command line, this option has no effect, since no | |
| <code>#line</code> directives are emitted whatsoever. | |
| <br><dt><code>-fno-show-column</code><dd><a name="index-fno_002dshow_002dcolumn-1004"></a>Do not print column numbers in diagnostics. This may be necessary if | |
| diagnostics are being scanned by a program that does not understand the | |
| column numbers, such as <samp><span class="command">dejagnu</span></samp>. | |
| <br><dt><code>-A </code><var>predicate</var><code>=</code><var>answer</var><dd><a name="index-A-1005"></a>Make an assertion with the predicate <var>predicate</var> and answer | |
| <var>answer</var>. This form is preferred to the older form <samp><span class="option">-A | |
| </span><var>predicate</var><span class="option">(</span><var>answer</var><span class="option">)</span></samp>, which is still supported, because | |
| it does not use shell special characters. | |
| <br><dt><code>-A -</code><var>predicate</var><code>=</code><var>answer</var><dd>Cancel an assertion with the predicate <var>predicate</var> and answer | |
| <var>answer</var>. | |
| <br><dt><code>-dCHARS</code><dd><var>CHARS</var> is a sequence of one or more of the following characters, | |
| and must not be preceded by a space. Other characters are interpreted | |
| by the compiler proper, or reserved for future versions of GCC, and so | |
| are silently ignored. If you specify characters whose behavior | |
| conflicts, the result is undefined. | |
| <dl> | |
| <dt>‘<samp><span class="samp">M</span></samp>’<dd><a name="index-dM-1006"></a>Instead of the normal output, generate a list of ‘<samp><span class="samp">#define</span></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><span class="file">foo.h</span></samp>, the command | |
| <pre class="smallexample"> touch foo.h; cpp -dM foo.h | |
| </pre> | |
| <p class="noindent">will show all the predefined macros. | |
| <p>If you use <samp><span class="option">-dM</span></samp> without the <samp><span class="option">-E</span></samp> option, <samp><span class="option">-dM</span></samp> is | |
| interpreted as a synonym for <samp><span class="option">-fdump-rtl-mach</span></samp>. | |
| See <a href="../gcc/Debugging-Options.html#Debugging-Options">Debugging Options</a>. | |
| <br><dt>‘<samp><span class="samp">D</span></samp>’<dd><a name="index-dD-1007"></a>Like ‘<samp><span class="samp">M</span></samp>’ except in two respects: it does <em>not</em> include the | |
| predefined macros, and it outputs <em>both</em> the ‘<samp><span class="samp">#define</span></samp>’ | |
| directives and the result of preprocessing. Both kinds of output go to | |
| the standard output file. | |
| <br><dt>‘<samp><span class="samp">N</span></samp>’<dd><a name="index-dN-1008"></a>Like ‘<samp><span class="samp">D</span></samp>’, but emit only the macro names, not their expansions. | |
| <br><dt>‘<samp><span class="samp">I</span></samp>’<dd><a name="index-dI-1009"></a>Output ‘<samp><span class="samp">#include</span></samp>’ directives in addition to the result of | |
| preprocessing. | |
| <br><dt>‘<samp><span class="samp">U</span></samp>’<dd><a name="index-dU-1010"></a>Like ‘<samp><span class="samp">D</span></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><span class="samp">#undef</span></samp>’ directives are also output for macros tested but | |
| undefined at the time. | |
| </dl> | |
| <br><dt><code>-P</code><dd><a name="index-P-1011"></a>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. | |
| <br><dt><code>-C</code><dd><a name="index-C-1012"></a>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>You should be prepared for side effects when using <samp><span class="option">-C</span></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><span class="samp">#</span></samp>’. | |
| <br><dt><code>-CC</code><dd>Do not discard comments, including during macro expansion. This is | |
| like <samp><span class="option">-C</span></samp>, except that comments contained within macros are | |
| also passed through to the output file where the macro is expanded. | |
| <p>In addition to the side-effects of the <samp><span class="option">-C</span></samp> option, the | |
| <samp><span class="option">-CC</span></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>The <samp><span class="option">-CC</span></samp> option is generally used to support lint comments. | |
| <br><dt><code>-traditional-cpp</code><dd><a name="index-traditional_002dcpp-1013"></a>Try to imitate the behavior of old-fashioned C preprocessors, as | |
| opposed to ISO C preprocessors. | |
| <br><dt><code>-trigraphs</code><dd><a name="index-trigraphs-1014"></a>Process trigraph sequences. | |
| These are three-character sequences, all starting with ‘<samp><span class="samp">??</span></samp>’, that | |
| are defined by ISO C to stand for single characters. For example, | |
| ‘<samp><span class="samp">??/</span></samp>’ stands for ‘<samp><span class="samp">\</span></samp>’, so ‘<samp><span class="samp">'??/n'</span></samp>’ is a character | |
| constant for a newline. By default, GCC ignores trigraphs, but in | |
| standard-conforming modes it converts them. See the <samp><span class="option">-std</span></samp> and | |
| <samp><span class="option">-ansi</span></samp> options. | |
| <p>The nine trigraphs and their replacements are | |
| <pre class="smallexample"> Trigraph: ??( ??) ??< ??> ??= ??/ ??' ??! ??- | |
| Replacement: [ ] { } # \ ^ | ~ | |
| </pre> | |
| <br><dt><code>-remap</code><dd><a name="index-remap-1015"></a>Enable special code to work around file systems which only permit very | |
| short file names, such as MS-DOS. | |
| <br><dt><code>--help</code><dt><code>--target-help</code><dd><a name="index-help-1016"></a><a name="index-target_002dhelp-1017"></a>Print text describing all the command line options instead of | |
| preprocessing anything. | |
| <br><dt><code>-v</code><dd><a name="index-v-1018"></a>Verbose mode. Print out GNU CPP's version number at the beginning of | |
| execution, and report the final form of the include path. | |
| <br><dt><code>-H</code><dd><a name="index-H-1019"></a>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><span class="samp">#include</span></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><span class="samp">...x</span></samp>’ and a valid one with ‘<samp><span class="samp">...!</span></samp>’ . | |
| <br><dt><code>-version</code><dt><code>--version</code><dd><a name="index-version-1020"></a>Print out GNU CPP's version number. With one dash, proceed to | |
| preprocess as normal. With two dashes, exit immediately. | |
| </dl> | |
| </body></html> | |