1<html lang="en"> 2<head> 3<title>Preprocessor Options - Using the GNU Compiler Collection (GCC)</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Using the GNU Compiler Collection (GCC)"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC"> 9<link rel="prev" href="Optimize-Options.html#Optimize-Options" title="Optimize Options"> 10<link rel="next" href="Assembler-Options.html#Assembler-Options" title="Assembler Options"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13Copyright (C) 1988-2013 Free Software Foundation, Inc. 14 15Permission is granted to copy, distribute and/or modify this document 16under the terms of the GNU Free Documentation License, Version 1.3 or 17any later version published by the Free Software Foundation; with the 18Invariant Sections being ``Funding Free Software'', the Front-Cover 19Texts being (a) (see below), and with the Back-Cover Texts being (b) 20(see below). A copy of the license is included in the section entitled 21``GNU Free Documentation License''. 22 23(a) The FSF's Front-Cover Text is: 24 25 A GNU Manual 26 27(b) The FSF's Back-Cover Text is: 28 29 You have freedom to copy and modify this GNU Manual, like GNU 30 software. Copies published by the Free Software Foundation raise 31 funds for GNU development.--> 32<meta http-equiv="Content-Style-Type" content="text/css"> 33<style type="text/css"><!-- 34 pre.display { font-family:inherit } 35 pre.format { font-family:inherit } 36 pre.smalldisplay { font-family:inherit; font-size:smaller } 37 pre.smallformat { font-family:inherit; font-size:smaller } 38 pre.smallexample { font-size:smaller } 39 pre.smalllisp { font-size:smaller } 40 span.sc { font-variant:small-caps } 41 span.roman { font-family:serif; font-weight:normal; } 42 span.sansserif { font-family:sans-serif; font-weight:normal; } 43--></style> 44<link rel="stylesheet" type="text/css" href="../cs.css"> 45</head> 46<body> 47<div class="node"> 48<a name="Preprocessor-Options"></a> 49<p> 50Next: <a rel="next" accesskey="n" href="Assembler-Options.html#Assembler-Options">Assembler Options</a>, 51Previous: <a rel="previous" accesskey="p" href="Optimize-Options.html#Optimize-Options">Optimize Options</a>, 52Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a> 53<hr> 54</div> 55 56<h3 class="section">3.11 Options Controlling the Preprocessor</h3> 57 58<p><a name="index-preprocessor-options-937"></a><a name="index-options_002c-preprocessor-938"></a> 59These options control the C preprocessor, which is run on each C source 60file before actual compilation. 61 62 <p>If you use the <samp><span class="option">-E</span></samp> option, nothing is done except preprocessing. 63Some of these options make sense only together with <samp><span class="option">-E</span></samp> because 64they cause the preprocessor output to be unsuitable for actual 65compilation. 66 67 <dl> 68<dt><code>-Wp,</code><var>option</var><dd><a name="index-Wp-939"></a>You can use <samp><span class="option">-Wp,</span><var>option</var></samp> to bypass the compiler driver 69and pass <var>option</var> directly through to the preprocessor. If 70<var>option</var> contains commas, it is split into multiple options at the 71commas. However, many options are modified, translated or interpreted 72by the compiler driver before being passed to the preprocessor, and 73<samp><span class="option">-Wp</span></samp> forcibly bypasses this phase. The preprocessor's direct 74interface is undocumented and subject to change, so whenever possible 75you should avoid using <samp><span class="option">-Wp</span></samp> and let the driver handle the 76options instead. 77 78 <br><dt><code>-Xpreprocessor </code><var>option</var><dd><a name="index-Xpreprocessor-940"></a>Pass <var>option</var> as an option to the preprocessor. You can use this to 79supply system-specific preprocessor options that GCC does not 80recognize. 81 82 <p>If you want to pass an option that takes an argument, you must use 83<samp><span class="option">-Xpreprocessor</span></samp> twice, once for the option and once for the argument. 84 85 <br><dt><code>-no-integrated-cpp</code><dd><a name="index-no_002dintegrated_002dcpp-941"></a>Perform preprocessing as a separate pass before compilation. 86By default, GCC performs preprocessing as an integrated part of 87input tokenization and parsing. 88If this option is provided, the appropriate language front end 89(<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++, 90and Objective-C, respectively) is instead invoked twice, 91once for preprocessing only and once for actual compilation 92of the preprocessed input. 93This option may be useful in conjunction with the <samp><span class="option">-B</span></samp> or 94<samp><span class="option">-wrapper</span></samp> options to specify an alternate preprocessor or 95perform additional processing of the program source between 96normal preprocessing and compilation. 97</dl> 98 99<!-- Copyright (C) 1999-2013 Free Software Foundation, Inc. --> 100<!-- This is part of the CPP and GCC manuals. --> 101<!-- For copying conditions, see the file gcc.texi. --> 102<!-- --> 103<!-- Options affecting the preprocessor --> 104<!-- --> 105<!-- If this file is included with the flag ``cppmanual'' set, it is --> 106<!-- formatted for inclusion in the CPP manual; otherwise the main GCC manual. --> 107 <dl> 108<dt><code>-D </code><var>name</var><dd><a name="index-D-942"></a>Predefine <var>name</var> as a macro, with definition <code>1</code>. 109 110 <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 111they appeared during translation phase three in a ‘<samp><span class="samp">#define</span></samp>’ 112directive. In particular, the definition will be truncated by 113embedded newline characters. 114 115 <p>If you are invoking the preprocessor from a shell or shell-like 116program you may need to use the shell's quoting syntax to protect 117characters such as spaces that have a meaning in the shell syntax. 118 119 <p>If you wish to define a function-like macro on the command line, write 120its argument list with surrounding parentheses before the equals sign 121(if any). Parentheses are meaningful to most shells, so you will need 122to quote the option. With <samp><span class="command">sh</span></samp> and <samp><span class="command">csh</span></samp>, 123<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. 124 125 <p><samp><span class="option">-D</span></samp> and <samp><span class="option">-U</span></samp> options are processed in the order they 126are given on the command line. All <samp><span class="option">-imacros </span><var>file</var></samp> and 127<samp><span class="option">-include </span><var>file</var></samp> options are processed after all 128<samp><span class="option">-D</span></samp> and <samp><span class="option">-U</span></samp> options. 129 130 <br><dt><code>-U </code><var>name</var><dd><a name="index-U-943"></a>Cancel any previous definition of <var>name</var>, either built in or 131provided with a <samp><span class="option">-D</span></samp> option. 132 133 <br><dt><code>-undef</code><dd><a name="index-undef-944"></a>Do not predefine any system-specific or GCC-specific macros. The 134standard predefined macros remain defined. 135 136 <br><dt><code>-I </code><var>dir</var><dd><a name="index-I-945"></a>Add the directory <var>dir</var> to the list of directories to be searched 137for header files. 138Directories named by <samp><span class="option">-I</span></samp> are searched before the standard 139system include directories. If the directory <var>dir</var> is a standard 140system include directory, the option is ignored to ensure that the 141default search order for system directories and the special treatment 142of system headers are not defeated 143. 144If <var>dir</var> begins with <code>=</code>, then the <code>=</code> will be replaced 145by the sysroot prefix; see <samp><span class="option">--sysroot</span></samp> and <samp><span class="option">-isysroot</span></samp>. 146 147 <br><dt><code>-o </code><var>file</var><dd><a name="index-o-946"></a>Write output to <var>file</var>. This is the same as specifying <var>file</var> 148as the second non-option argument to <samp><span class="command">cpp</span></samp>. <samp><span class="command">gcc</span></samp> has a 149different interpretation of a second non-option argument, so you must 150use <samp><span class="option">-o</span></samp> to specify the output file. 151 152 <br><dt><code>-Wall</code><dd><a name="index-Wall-947"></a>Turns on all optional warnings which are desirable for normal code. 153At present this is <samp><span class="option">-Wcomment</span></samp>, <samp><span class="option">-Wtrigraphs</span></samp>, 154<samp><span class="option">-Wmultichar</span></samp> and a warning about integer promotion causing a 155change of sign in <code>#if</code> expressions. Note that many of the 156preprocessor's warnings are on by default and have no options to 157control them. 158 159 <br><dt><code>-Wcomment</code><dt><code>-Wcomments</code><dd><a name="index-Wcomment-948"></a><a name="index-Wcomments-949"></a>Warn whenever a comment-start sequence ‘<samp><span class="samp">/*</span></samp>’ appears in a ‘<samp><span class="samp">/*</span></samp>’ 160comment, or whenever a backslash-newline appears in a ‘<samp><span class="samp">//</span></samp>’ comment. 161(Both forms have the same effect.) 162 163 <br><dt><code>-Wtrigraphs</code><dd><a name="index-Wtrigraphs-950"></a><a name="Wtrigraphs"></a>Most trigraphs in comments cannot affect the meaning of the program. 164However, a trigraph that would form an escaped newline (‘<samp><span class="samp">??/</span></samp>’ at 165the end of a line) can, by changing where the comment begins or ends. 166Therefore, only trigraphs that would form escaped newlines produce 167warnings inside a comment. 168 169 <p>This option is implied by <samp><span class="option">-Wall</span></samp>. If <samp><span class="option">-Wall</span></samp> is not 170given, this option is still enabled unless trigraphs are enabled. To 171get trigraph conversion without warnings, but get the other 172<samp><span class="option">-Wall</span></samp> warnings, use ‘<samp><span class="samp">-trigraphs -Wall -Wno-trigraphs</span></samp>’. 173 174 <br><dt><code>-Wtraditional</code><dd><a name="index-Wtraditional-951"></a>Warn about certain constructs that behave differently in traditional and 175ISO C. Also warn about ISO C constructs that have no traditional C 176equivalent, and problematic constructs which should be avoided. 177 178 <br><dt><code>-Wundef</code><dd><a name="index-Wundef-952"></a>Warn whenever an identifier which is not a macro is encountered in an 179‘<samp><span class="samp">#if</span></samp>’ directive, outside of ‘<samp><span class="samp">defined</span></samp>’. Such identifiers are 180replaced with zero. 181 182 <br><dt><code>-Wunused-macros</code><dd><a name="index-Wunused_002dmacros-953"></a>Warn about macros defined in the main file that are unused. A macro 183is <dfn>used</dfn> if it is expanded or tested for existence at least once. 184The preprocessor will also warn if the macro has not been used at the 185time it is redefined or undefined. 186 187 <p>Built-in macros, macros defined on the command line, and macros 188defined in include files are not warned about. 189 190 <p><em>Note:</em> If a macro is actually used, but only used in skipped 191conditional blocks, then CPP will report it as unused. To avoid the 192warning in such a case, you might improve the scope of the macro's 193definition by, for example, moving it into the first skipped block. 194Alternatively, you could provide a dummy use with something like: 195 196 <pre class="smallexample"> #if defined the_macro_causing_the_warning 197 #endif 198</pre> 199 <br><dt><code>-Wendif-labels</code><dd><a name="index-Wendif_002dlabels-954"></a>Warn whenever an ‘<samp><span class="samp">#else</span></samp>’ or an ‘<samp><span class="samp">#endif</span></samp>’ are followed by text. 200This usually happens in code of the form 201 202 <pre class="smallexample"> #if FOO 203 ... 204 #else FOO 205 ... 206 #endif FOO 207</pre> 208 <p class="noindent">The second and third <code>FOO</code> should be in comments, but often are not 209in older programs. This warning is on by default. 210 211 <br><dt><code>-Werror</code><dd><a name="index-Werror-955"></a>Make all warnings into hard errors. Source code which triggers warnings 212will be rejected. 213 214 <br><dt><code>-Wsystem-headers</code><dd><a name="index-Wsystem_002dheaders-956"></a>Issue warnings for code in system headers. These are normally unhelpful 215in finding bugs in your own code, therefore suppressed. If you are 216responsible for the system library, you may want to see them. 217 218 <br><dt><code>-w</code><dd><a name="index-w-957"></a>Suppress all warnings, including those which GNU CPP issues by default. 219 220 <br><dt><code>-pedantic</code><dd><a name="index-pedantic-958"></a>Issue all the mandatory diagnostics listed in the C standard. Some of 221them are left out by default, since they trigger frequently on harmless 222code. 223 224 <br><dt><code>-pedantic-errors</code><dd><a name="index-pedantic_002derrors-959"></a>Issue all the mandatory diagnostics, and make all mandatory diagnostics 225into errors. This includes mandatory diagnostics that GCC issues 226without ‘<samp><span class="samp">-pedantic</span></samp>’ but treats as warnings. 227 228 <br><dt><code>-M</code><dd><a name="index-M-960"></a><a name="index-g_t_0040command_007bmake_007d-961"></a><a name="index-dependencies_002c-_0040command_007bmake_007d-962"></a>Instead of outputting the result of preprocessing, output a rule 229suitable for <samp><span class="command">make</span></samp> describing the dependencies of the main 230source file. The preprocessor outputs one <samp><span class="command">make</span></samp> rule containing 231the object file name for that source file, a colon, and the names of all 232the included files, including those coming from <samp><span class="option">-include</span></samp> or 233<samp><span class="option">-imacros</span></samp> command line options. 234 235 <p>Unless specified explicitly (with <samp><span class="option">-MT</span></samp> or <samp><span class="option">-MQ</span></samp>), the 236object file name consists of the name of the source file with any 237suffix replaced with object file suffix and with any leading directory 238parts removed. If there are many included files then the rule is 239split into several lines using ‘<samp><span class="samp">\</span></samp>’-newline. The rule has no 240commands. 241 242 <p>This option does not suppress the preprocessor's debug output, such as 243<samp><span class="option">-dM</span></samp>. To avoid mixing such debug output with the dependency 244rules you should explicitly specify the dependency output file with 245<samp><span class="option">-MF</span></samp>, or use an environment variable like 246<samp><span class="env">DEPENDENCIES_OUTPUT</span></samp> (see <a href="Environment-Variables.html#Environment-Variables">Environment Variables</a>). Debug output 247will still be sent to the regular output stream as normal. 248 249 <p>Passing <samp><span class="option">-M</span></samp> to the driver implies <samp><span class="option">-E</span></samp>, and suppresses 250warnings with an implicit <samp><span class="option">-w</span></samp>. 251 252 <br><dt><code>-MM</code><dd><a name="index-MM-963"></a>Like <samp><span class="option">-M</span></samp> but do not mention header files that are found in 253system header directories, nor header files that are included, 254directly or indirectly, from such a header. 255 256 <p>This implies that the choice of angle brackets or double quotes in an 257‘<samp><span class="samp">#include</span></samp>’ directive does not in itself determine whether that 258header will appear in <samp><span class="option">-MM</span></samp> dependency output. This is a 259slight change in semantics from GCC versions 3.0 and earlier. 260 261 <p><a name="dashMF"></a><br><dt><code>-MF </code><var>file</var><dd><a name="index-MF-964"></a>When used with <samp><span class="option">-M</span></samp> or <samp><span class="option">-MM</span></samp>, specifies a 262file to write the dependencies to. If no <samp><span class="option">-MF</span></samp> switch is given 263the preprocessor sends the rules to the same place it would have sent 264preprocessed output. 265 266 <p>When used with the driver options <samp><span class="option">-MD</span></samp> or <samp><span class="option">-MMD</span></samp>, 267<samp><span class="option">-MF</span></samp> overrides the default dependency output file. 268 269 <br><dt><code>-MG</code><dd><a name="index-MG-965"></a>In conjunction with an option such as <samp><span class="option">-M</span></samp> requesting 270dependency generation, <samp><span class="option">-MG</span></samp> assumes missing header files are 271generated files and adds them to the dependency list without raising 272an error. The dependency filename is taken directly from the 273<code>#include</code> directive without prepending any path. <samp><span class="option">-MG</span></samp> 274also suppresses preprocessed output, as a missing header file renders 275this useless. 276 277 <p>This feature is used in automatic updating of makefiles. 278 279 <br><dt><code>-MP</code><dd><a name="index-MP-966"></a>This option instructs CPP to add a phony target for each dependency 280other than the main file, causing each to depend on nothing. These 281dummy rules work around errors <samp><span class="command">make</span></samp> gives if you remove header 282files without updating the <samp><span class="file">Makefile</span></samp> to match. 283 284 <p>This is typical output: 285 286 <pre class="smallexample"> test.o: test.c test.h 287 288 test.h: 289</pre> 290 <br><dt><code>-MT </code><var>target</var><dd><a name="index-MT-967"></a> 291Change the target of the rule emitted by dependency generation. By 292default CPP takes the name of the main input file, deletes any 293directory components and any file suffix such as ‘<samp><span class="samp">.c</span></samp>’, and 294appends the platform's usual object suffix. The result is the target. 295 296 <p>An <samp><span class="option">-MT</span></samp> option will set the target to be exactly the string you 297specify. If you want multiple targets, you can specify them as a single 298argument to <samp><span class="option">-MT</span></samp>, or use multiple <samp><span class="option">-MT</span></samp> options. 299 300 <p>For example, <samp><span class="option">-MT '$(objpfx)foo.o'<!-- /@w --></span></samp> might give 301 302 <pre class="smallexample"> $(objpfx)foo.o: foo.c 303</pre> 304 <br><dt><code>-MQ </code><var>target</var><dd><a name="index-MQ-968"></a> 305Same as <samp><span class="option">-MT</span></samp>, but it quotes any characters which are special to 306Make. <samp><span class="option">-MQ '$(objpfx)foo.o'<!-- /@w --></span></samp> gives 307 308 <pre class="smallexample"> $$(objpfx)foo.o: foo.c 309</pre> 310 <p>The default target is automatically quoted, as if it were given with 311<samp><span class="option">-MQ</span></samp>. 312 313 <br><dt><code>-MD</code><dd><a name="index-MD-969"></a><samp><span class="option">-MD</span></samp> is equivalent to <samp><span class="option">-M -MF </span><var>file</var></samp>, except that 314<samp><span class="option">-E</span></samp> is not implied. The driver determines <var>file</var> based on 315whether an <samp><span class="option">-o</span></samp> option is given. If it is, the driver uses its 316argument but with a suffix of <samp><span class="file">.d</span></samp>, otherwise it takes the name 317of the input file, removes any directory components and suffix, and 318applies a <samp><span class="file">.d</span></samp> suffix. 319 320 <p>If <samp><span class="option">-MD</span></samp> is used in conjunction with <samp><span class="option">-E</span></samp>, any 321<samp><span class="option">-o</span></samp> switch is understood to specify the dependency output file 322(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> 323is understood to specify a target object file. 324 325 <p>Since <samp><span class="option">-E</span></samp> is not implied, <samp><span class="option">-MD</span></samp> can be used to generate 326a dependency output file as a side-effect of the compilation process. 327 328 <br><dt><code>-MMD</code><dd><a name="index-MMD-970"></a>Like <samp><span class="option">-MD</span></samp> except mention only user header files, not system 329header files. 330 331 <br><dt><code>-fpch-deps</code><dd><a name="index-fpch_002ddeps-971"></a>When using precompiled headers (see <a href="Precompiled-Headers.html#Precompiled-Headers">Precompiled Headers</a>), this flag 332will cause the dependency-output flags to also list the files from the 333precompiled header's dependencies. If not specified only the 334precompiled header would be listed and not the files that were used to 335create it because those files are not consulted when a precompiled 336header is used. 337 338 <br><dt><code>-fpch-preprocess</code><dd><a name="index-fpch_002dpreprocess-972"></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>, 339<code>#pragma GCC pch_preprocess "</code><var>filename</var><code>"</code> in the output to mark 340the place where the precompiled header was found, and its <var>filename</var>. 341When <samp><span class="option">-fpreprocessed</span></samp> is in use, GCC recognizes this <code>#pragma</code> 342and loads the PCH. 343 344 <p>This option is off by default, because the resulting preprocessed output 345is only really suitable as input to GCC. It is switched on by 346<samp><span class="option">-save-temps</span></samp>. 347 348 <p>You should not write this <code>#pragma</code> in your own code, but it is 349safe to edit the filename if the PCH file is available in a different 350location. The filename may be absolute or it may be relative to GCC's 351current directory. 352 353 <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-973"></a>Specify the source language: C, C++, Objective-C, or assembly. This has 354nothing to do with standards conformance or extensions; it merely 355selects which base syntax to expect. If you give none of these options, 356cpp will deduce the language from the extension of the source file: 357‘<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 358extensions for C++ and assembly are also recognized. If cpp does not 359recognize the extension, it will treat the file as C; this is the most 360generic mode. 361 362 <p><em>Note:</em> Previous versions of cpp accepted a <samp><span class="option">-lang</span></samp> option 363which selected both the language and the standards conformance level. 364This option has been removed, because it conflicts with the <samp><span class="option">-l</span></samp> 365option. 366 367 <br><dt><code>-std=</code><var>standard</var><dt><code>-ansi</code><dd><a name="index-ansi-974"></a><a name="index-std_003d-975"></a>Specify the standard to which the code should conform. Currently CPP 368knows about C and C++ standards; others may be added in the future. 369 370 <p><var>standard</var> 371may be one of: 372 <dl> 373<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 374this version of the standard. 375 376 <p>The <samp><span class="option">-ansi</span></samp> option is equivalent to <samp><span class="option">-std=c90</span></samp>. 377 378 <br><dt><code>iso9899:199409</code><dd>The 1990 C standard, as amended in 1994. 379 380 <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 381publication, this was known as C9X. 382 383 <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 384publication, this was known as C1X. 385 386 <br><dt><code>gnu90</code><dt><code>gnu89</code><dd>The 1990 C standard plus GNU extensions. This is the default. 387 388 <br><dt><code>gnu99</code><dt><code>gnu9x</code><dd>The 1999 C standard plus GNU extensions. 389 390 <br><dt><code>gnu11</code><dt><code>gnu1x</code><dd>The 2011 C standard plus GNU extensions. 391 392 <br><dt><code>c++98</code><dd>The 1998 ISO C++ standard plus amendments. 393 394 <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 395default for C++ code. 396</dl> 397 398 <br><dt><code>-I-</code><dd><a name="index-I_002d-976"></a>Split the include path. Any directories specified with <samp><span class="option">-I</span></samp> 399options before <samp><span class="option">-I-</span></samp> are searched only for headers requested with 400<code>#include "</code><var>file</var><code>"<!-- /@w --></code>; they are not searched for 401<code>#include <</code><var>file</var><code>><!-- /@w --></code>. If additional directories are 402specified with <samp><span class="option">-I</span></samp> options after the <samp><span class="option">-I-</span></samp>, those 403directories are searched for all ‘<samp><span class="samp">#include</span></samp>’ directives. 404 405 <p>In addition, <samp><span class="option">-I-</span></samp> inhibits the use of the directory of the current 406file directory as the first search directory for <code>#include "</code><var>file</var><code>"<!-- /@w --></code>. 407This option has been deprecated. 408 409 <br><dt><code>-nostdinc</code><dd><a name="index-nostdinc-977"></a>Do not search the standard system directories for header files. 410Only the directories you have specified with <samp><span class="option">-I</span></samp> options 411(and the directory of the current file, if appropriate) are searched. 412 413 <br><dt><code>-nostdinc++</code><dd><a name="index-nostdinc_002b_002b-978"></a>Do not search for header files in the C++-specific standard directories, 414but do still search the other standard directories. (This option is 415used when building the C++ library.) 416 417 <br><dt><code>-include </code><var>file</var><dd><a name="index-include-979"></a>Process <var>file</var> as if <code>#include "file"</code> appeared as the first 418line of the primary source file. However, the first directory searched 419for <var>file</var> is the preprocessor's working directory <em>instead of</em> 420the directory containing the main source file. If not found there, it 421is searched for in the remainder of the <code>#include "..."</code> search 422chain as normal. 423 424 <p>If multiple <samp><span class="option">-include</span></samp> options are given, the files are included 425in the order they appear on the command line. 426 427 <br><dt><code>-imacros </code><var>file</var><dd><a name="index-imacros-980"></a>Exactly like <samp><span class="option">-include</span></samp>, except that any output produced by 428scanning <var>file</var> is thrown away. Macros it defines remain defined. 429This allows you to acquire all the macros from a header without also 430processing its declarations. 431 432 <p>All files specified by <samp><span class="option">-imacros</span></samp> are processed before all files 433specified by <samp><span class="option">-include</span></samp>. 434 435 <br><dt><code>-idirafter </code><var>dir</var><dd><a name="index-idirafter-981"></a>Search <var>dir</var> for header files, but do it <em>after</em> all 436directories specified with <samp><span class="option">-I</span></samp> and the standard system directories 437have been exhausted. <var>dir</var> is treated as a system include directory. 438If <var>dir</var> begins with <code>=</code>, then the <code>=</code> will be replaced 439by the sysroot prefix; see <samp><span class="option">--sysroot</span></samp> and <samp><span class="option">-isysroot</span></samp>. 440 441 <br><dt><code>-iprefix </code><var>prefix</var><dd><a name="index-iprefix-982"></a>Specify <var>prefix</var> as the prefix for subsequent <samp><span class="option">-iwithprefix</span></samp> 442options. If the prefix represents a directory, you should include the 443final ‘<samp><span class="samp">/</span></samp>’. 444 445 <br><dt><code>-iwithprefix </code><var>dir</var><dt><code>-iwithprefixbefore </code><var>dir</var><dd><a name="index-iwithprefix-983"></a><a name="index-iwithprefixbefore-984"></a>Append <var>dir</var> to the prefix specified previously with 446<samp><span class="option">-iprefix</span></samp>, and add the resulting directory to the include search 447path. <samp><span class="option">-iwithprefixbefore</span></samp> puts it in the same place <samp><span class="option">-I</span></samp> 448would; <samp><span class="option">-iwithprefix</span></samp> puts it where <samp><span class="option">-idirafter</span></samp> would. 449 450 <br><dt><code>-isysroot </code><var>dir</var><dd><a name="index-isysroot-985"></a>This option is like the <samp><span class="option">--sysroot</span></samp> option, but applies only to 451header files (except for Darwin targets, where it applies to both header 452files and libraries). See the <samp><span class="option">--sysroot</span></samp> option for more 453information. 454 455 <br><dt><code>-imultilib </code><var>dir</var><dd><a name="index-imultilib-986"></a>Use <var>dir</var> as a subdirectory of the directory containing 456target-specific C++ headers. 457 458 <br><dt><code>-isystem </code><var>dir</var><dd><a name="index-isystem-987"></a>Search <var>dir</var> for header files, after all directories specified by 459<samp><span class="option">-I</span></samp> but before the standard system directories. Mark it 460as a system directory, so that it gets the same special treatment as 461is applied to the standard system directories. 462If <var>dir</var> begins with <code>=</code>, then the <code>=</code> will be replaced 463by the sysroot prefix; see <samp><span class="option">--sysroot</span></samp> and <samp><span class="option">-isysroot</span></samp>. 464 465 <br><dt><code>-iquote </code><var>dir</var><dd><a name="index-iquote-988"></a>Search <var>dir</var> only for header files requested with 466<code>#include "</code><var>file</var><code>"<!-- /@w --></code>; they are not searched for 467<code>#include <</code><var>file</var><code>><!-- /@w --></code>, before all directories specified by 468<samp><span class="option">-I</span></samp> and before the standard system directories. 469If <var>dir</var> begins with <code>=</code>, then the <code>=</code> will be replaced 470by the sysroot prefix; see <samp><span class="option">--sysroot</span></samp> and <samp><span class="option">-isysroot</span></samp>. 471 472 <br><dt><code>-fdirectives-only</code><dd><a name="index-fdirectives_002donly-989"></a>When preprocessing, handle directives, but do not expand macros. 473 474 <p>The option's behavior depends on the <samp><span class="option">-E</span></samp> and <samp><span class="option">-fpreprocessed</span></samp> 475options. 476 477 <p>With <samp><span class="option">-E</span></samp>, preprocessing is limited to the handling of directives 478such as <code>#define</code>, <code>#ifdef</code>, and <code>#error</code>. Other 479preprocessor operations, such as macro expansion and trigraph 480conversion are not performed. In addition, the <samp><span class="option">-dD</span></samp> option is 481implicitly enabled. 482 483 <p>With <samp><span class="option">-fpreprocessed</span></samp>, predefinition of command line and most 484builtin macros is disabled. Macros such as <code>__LINE__</code>, which are 485contextually dependent, are handled normally. This enables compilation of 486files previously preprocessed with <code>-E -fdirectives-only</code>. 487 488 <p>With both <samp><span class="option">-E</span></samp> and <samp><span class="option">-fpreprocessed</span></samp>, the rules for 489<samp><span class="option">-fpreprocessed</span></samp> take precedence. This enables full preprocessing of 490files previously preprocessed with <code>-E -fdirectives-only</code>. 491 492 <br><dt><code>-fdollars-in-identifiers</code><dd><a name="index-fdollars_002din_002didentifiers-990"></a><a name="fdollars_002din_002didentifiers"></a>Accept ‘<samp><span class="samp">$</span></samp>’ in identifiers. 493 494 <br><dt><code>-fextended-identifiers</code><dd><a name="index-fextended_002didentifiers-991"></a>Accept universal character names in identifiers. This option is 495experimental; in a future version of GCC, it will be enabled by 496default for C99 and C++. 497 498 <br><dt><code>-fno-canonical-system-headers</code><dd><a name="index-fno_002dcanonical_002dsystem_002dheaders-992"></a>When preprocessing, do not shorten system header paths with canonicalization. 499 500 <br><dt><code>-fpreprocessed</code><dd><a name="index-fpreprocessed-993"></a>Indicate to the preprocessor that the input file has already been 501preprocessed. This suppresses things like macro expansion, trigraph 502conversion, escaped newline splicing, and processing of most directives. 503The preprocessor still recognizes and removes comments, so that you can 504pass a file preprocessed with <samp><span class="option">-C</span></samp> to the compiler without 505problems. In this mode the integrated preprocessor is little more than 506a tokenizer for the front ends. 507 508 <p><samp><span class="option">-fpreprocessed</span></samp> is implicit if the input file has one of the 509extensions ‘<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 510extensions that GCC uses for preprocessed files created by 511<samp><span class="option">-save-temps</span></samp>. 512 513 <br><dt><code>-ftabstop=</code><var>width</var><dd><a name="index-ftabstop-994"></a>Set the distance between tab stops. This helps the preprocessor report 514correct column numbers in warnings or errors, even if tabs appear on the 515line. If the value is less than 1 or greater than 100, the option is 516ignored. The default is 8. 517 518 <br><dt><code>-fdebug-cpp</code><dd><a name="index-fdebug_002dcpp-995"></a>This option is only useful for debugging GCC. When used with 519<samp><span class="option">-E</span></samp>, dumps debugging information about location maps. Every 520token in the output is preceded by the dump of the map its location 521belongs to. The dump of the map holding the location of a token would 522be: 523 <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>} 524</pre> 525 <p>When used without <samp><span class="option">-E</span></samp>, this option has no effect. 526 527 <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-996"></a>Track locations of tokens across macro expansions. This allows the 528compiler to emit diagnostic about the current macro expansion stack 529when a compilation error occurs in a macro expansion. Using this 530option makes the preprocessor and the compiler consume more 531memory. The <var>level</var> parameter can be used to choose the level of 532precision of token location tracking thus decreasing the memory 533consumption if necessary. Value ‘<samp><span class="samp">0</span></samp>’ of <var>level</var> de-activates 534this option just as if no <samp><span class="option">-ftrack-macro-expansion</span></samp> was present 535on the command line. Value ‘<samp><span class="samp">1</span></samp>’ tracks tokens locations in a 536degraded mode for the sake of minimal memory overhead. In this mode 537all tokens resulting from the expansion of an argument of a 538function-like macro have the same location. Value ‘<samp><span class="samp">2</span></samp>’ tracks 539tokens locations completely. This value is the most memory hungry. 540When this option is given no argument, the default parameter value is 541‘<samp><span class="samp">2</span></samp>’. 542 543 <p>Note that -ftrack-macro-expansion=2 is activated by default. 544 545 <br><dt><code>-fexec-charset=</code><var>charset</var><dd><a name="index-fexec_002dcharset-997"></a><a name="index-character-set_002c-execution-998"></a>Set the execution character set, used for string and character 546constants. The default is UTF-8. <var>charset</var> can be any encoding 547supported by the system's <code>iconv</code> library routine. 548 549 <br><dt><code>-fwide-exec-charset=</code><var>charset</var><dd><a name="index-fwide_002dexec_002dcharset-999"></a><a name="index-character-set_002c-wide-execution-1000"></a>Set the wide execution character set, used for wide string and 550character constants. The default is UTF-32 or UTF-16, whichever 551corresponds to the width of <code>wchar_t</code>. As with 552<samp><span class="option">-fexec-charset</span></samp>, <var>charset</var> can be any encoding supported 553by the system's <code>iconv</code> library routine; however, you will have 554problems with encodings that do not fit exactly in <code>wchar_t</code>. 555 556 <br><dt><code>-finput-charset=</code><var>charset</var><dd><a name="index-finput_002dcharset-1001"></a><a name="index-character-set_002c-input-1002"></a>Set the input character set, used for translation from the character 557set of the input file to the source character set used by GCC. If the 558locale does not specify, or GCC cannot get this information from the 559locale, the default is UTF-8. This can be overridden by either the locale 560or this command line option. Currently the command line option takes 561precedence if there's a conflict. <var>charset</var> can be any encoding 562supported by the system's <code>iconv</code> library routine. 563 564 <br><dt><code>-fworking-directory</code><dd><a name="index-fworking_002ddirectory-1003"></a><a name="index-fno_002dworking_002ddirectory-1004"></a>Enable generation of linemarkers in the preprocessor output that will 565let the compiler know the current working directory at the time of 566preprocessing. When this option is enabled, the preprocessor will 567emit, after the initial linemarker, a second linemarker with the 568current working directory followed by two slashes. GCC will use this 569directory, when it's present in the preprocessed input, as the 570directory emitted as the current working directory in some debugging 571information formats. This option is implicitly enabled if debugging 572information is enabled, but this can be inhibited with the negated 573form <samp><span class="option">-fno-working-directory</span></samp>. If the <samp><span class="option">-P</span></samp> flag is 574present in the command line, this option has no effect, since no 575<code>#line</code> directives are emitted whatsoever. 576 577 <br><dt><code>-fno-show-column</code><dd><a name="index-fno_002dshow_002dcolumn-1005"></a>Do not print column numbers in diagnostics. This may be necessary if 578diagnostics are being scanned by a program that does not understand the 579column numbers, such as <samp><span class="command">dejagnu</span></samp>. 580 581 <br><dt><code>-A </code><var>predicate</var><code>=</code><var>answer</var><dd><a name="index-A-1006"></a>Make an assertion with the predicate <var>predicate</var> and answer 582<var>answer</var>. This form is preferred to the older form <samp><span class="option">-A 583</span><var>predicate</var><span class="option">(</span><var>answer</var><span class="option">)</span></samp>, which is still supported, because 584it does not use shell special characters. 585 586 <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 587<var>answer</var>. 588 589 <br><dt><code>-dCHARS</code><dd><var>CHARS</var> is a sequence of one or more of the following characters, 590and must not be preceded by a space. Other characters are interpreted 591by the compiler proper, or reserved for future versions of GCC, and so 592are silently ignored. If you specify characters whose behavior 593conflicts, the result is undefined. 594 595 <dl> 596<dt>‘<samp><span class="samp">M</span></samp>’<dd><a name="index-dM-1007"></a>Instead of the normal output, generate a list of ‘<samp><span class="samp">#define</span></samp>’ 597directives for all the macros defined during the execution of the 598preprocessor, including predefined macros. This gives you a way of 599finding out what is predefined in your version of the preprocessor. 600Assuming you have no file <samp><span class="file">foo.h</span></samp>, the command 601 602 <pre class="smallexample"> touch foo.h; cpp -dM foo.h 603</pre> 604 <p class="noindent">will show all the predefined macros. 605 606 <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 607interpreted as a synonym for <samp><span class="option">-fdump-rtl-mach</span></samp>. 608See <a href="../gcc/Debugging-Options.html#Debugging-Options">Debugging Options</a>. 609 610 <br><dt>‘<samp><span class="samp">D</span></samp>’<dd><a name="index-dD-1008"></a>Like ‘<samp><span class="samp">M</span></samp>’ except in two respects: it does <em>not</em> include the 611predefined macros, and it outputs <em>both</em> the ‘<samp><span class="samp">#define</span></samp>’ 612directives and the result of preprocessing. Both kinds of output go to 613the standard output file. 614 615 <br><dt>‘<samp><span class="samp">N</span></samp>’<dd><a name="index-dN-1009"></a>Like ‘<samp><span class="samp">D</span></samp>’, but emit only the macro names, not their expansions. 616 617 <br><dt>‘<samp><span class="samp">I</span></samp>’<dd><a name="index-dI-1010"></a>Output ‘<samp><span class="samp">#include</span></samp>’ directives in addition to the result of 618preprocessing. 619 620 <br><dt>‘<samp><span class="samp">U</span></samp>’<dd><a name="index-dU-1011"></a>Like ‘<samp><span class="samp">D</span></samp>’ except that only macros that are expanded, or whose 621definedness is tested in preprocessor directives, are output; the 622output is delayed until the use or test of the macro; and 623‘<samp><span class="samp">#undef</span></samp>’ directives are also output for macros tested but 624undefined at the time. 625</dl> 626 627 <br><dt><code>-P</code><dd><a name="index-P-1012"></a>Inhibit generation of linemarkers in the output from the preprocessor. 628This might be useful when running the preprocessor on something that is 629not C code, and will be sent to a program which might be confused by the 630linemarkers. 631 632 <br><dt><code>-C</code><dd><a name="index-C-1013"></a>Do not discard comments. All comments are passed through to the output 633file, except for comments in processed directives, which are deleted 634along with the directive. 635 636 <p>You should be prepared for side effects when using <samp><span class="option">-C</span></samp>; it 637causes the preprocessor to treat comments as tokens in their own right. 638For example, comments appearing at the start of what would be a 639directive line have the effect of turning that line into an ordinary 640source line, since the first token on the line is no longer a ‘<samp><span class="samp">#</span></samp>’. 641 642 <br><dt><code>-CC</code><dd>Do not discard comments, including during macro expansion. This is 643like <samp><span class="option">-C</span></samp>, except that comments contained within macros are 644also passed through to the output file where the macro is expanded. 645 646 <p>In addition to the side-effects of the <samp><span class="option">-C</span></samp> option, the 647<samp><span class="option">-CC</span></samp> option causes all C++-style comments inside a macro 648to be converted to C-style comments. This is to prevent later use 649of that macro from inadvertently commenting out the remainder of 650the source line. 651 652 <p>The <samp><span class="option">-CC</span></samp> option is generally used to support lint comments. 653 654 <br><dt><code>-traditional-cpp</code><dd><a name="index-traditional_002dcpp-1014"></a>Try to imitate the behavior of old-fashioned C preprocessors, as 655opposed to ISO C preprocessors. 656 657 <br><dt><code>-trigraphs</code><dd><a name="index-trigraphs-1015"></a>Process trigraph sequences. 658These are three-character sequences, all starting with ‘<samp><span class="samp">??</span></samp>’, that 659are defined by ISO C to stand for single characters. For example, 660‘<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 661constant for a newline. By default, GCC ignores trigraphs, but in 662standard-conforming modes it converts them. See the <samp><span class="option">-std</span></samp> and 663<samp><span class="option">-ansi</span></samp> options. 664 665 <p>The nine trigraphs and their replacements are 666 667 <pre class="smallexample"> Trigraph: ??( ??) ??< ??> ??= ??/ ??' ??! ??- 668 Replacement: [ ] { } # \ ^ | ~ 669</pre> 670 <br><dt><code>-remap</code><dd><a name="index-remap-1016"></a>Enable special code to work around file systems which only permit very 671short file names, such as MS-DOS. 672 673 <br><dt><code>--help</code><dt><code>--target-help</code><dd><a name="index-help-1017"></a><a name="index-target_002dhelp-1018"></a>Print text describing all the command line options instead of 674preprocessing anything. 675 676 <br><dt><code>-v</code><dd><a name="index-v-1019"></a>Verbose mode. Print out GNU CPP's version number at the beginning of 677execution, and report the final form of the include path. 678 679 <br><dt><code>-H</code><dd><a name="index-H-1020"></a>Print the name of each header file used, in addition to other normal 680activities. Each name is indented to show how deep in the 681‘<samp><span class="samp">#include</span></samp>’ stack it is. Precompiled header files are also 682printed, even if they are found to be invalid; an invalid precompiled 683header file is printed with ‘<samp><span class="samp">...x</span></samp>’ and a valid one with ‘<samp><span class="samp">...!</span></samp>’ . 684 685 <br><dt><code>-version</code><dt><code>--version</code><dd><a name="index-version-1021"></a>Print out GNU CPP's version number. With one dash, proceed to 686preprocess as normal. With two dashes, exit immediately. 687</dl> 688 689 </body></html> 690 691