Invocation.html 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1987-2023 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation. A copy of
  7. the license is included in the
  8. section entitled "GNU Free Documentation License".
  9. This manual contains no Invariant Sections. The Front-Cover Texts are
  10. (a) (see below), and the Back-Cover Texts are (b) (see below).
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Invocation (The C Preprocessor)</title>
  21. <meta name="description" content="Invocation (The C Preprocessor)">
  22. <meta name="keywords" content="Invocation (The C Preprocessor)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html" rel="start" title="Top">
  27. <link href="Index-of-Directives.html" rel="index" title="Index of Directives">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="index.html" rel="up" title="Top">
  30. <link href="Environment-Variables.html" rel="next" title="Environment Variables">
  31. <link href="Obsolete-Features.html" rel="prev" title="Obsolete Features">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.lisp {margin-left: 3.2em}
  39. kbd {font-style: oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. span.nolinebreak {white-space: nowrap}
  45. span.roman {font-family: initial; font-weight: normal}
  46. span.sansserif {font-family: sans-serif; font-weight: normal}
  47. ul.no-bullet {list-style: none}
  48. -->
  49. </style>
  50. </head>
  51. <body lang="en">
  52. <span id="Invocation"></span><div class="header">
  53. <p>
  54. Next: <a href="Environment-Variables.html" accesskey="n" rel="next">Environment Variables</a>, Previous: <a href="Implementation-Details.html" accesskey="p" rel="prev">Implementation Details</a>, Up: <a href="index.html" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html" title="Index" rel="index">Index</a>]</p>
  55. </div>
  56. <hr>
  57. <span id="Invocation-1"></span><h2 class="chapter">12 Invocation</h2>
  58. <span id="index-invocation"></span>
  59. <span id="index-command-line"></span>
  60. <p>Most often when you use the C preprocessor you do not have to invoke it
  61. explicitly: the C compiler does so automatically. However, the
  62. preprocessor is sometimes useful on its own. You can invoke the
  63. preprocessor either with the <code>cpp</code> command, or via <code>gcc -E</code>.
  64. In GCC, the preprocessor is actually integrated with the compiler
  65. rather than a separate program, and both of these commands invoke
  66. GCC and tell it to stop after the preprocessing phase.
  67. </p>
  68. <p>The <code>cpp</code> options listed here are also accepted by
  69. <code>gcc</code> and have the same meaning. Likewise the <code>cpp</code>
  70. command accepts all the usual <code>gcc</code> driver options, although those
  71. pertaining to compilation phases after preprocessing are ignored.
  72. </p>
  73. <p>Only options specific to preprocessing behavior are documented here.
  74. Refer to the GCC manual for full documentation of other driver options.
  75. </p>
  76. <p>The <code>cpp</code> command expects two file names as arguments, <var>infile</var> and
  77. <var>outfile</var>. The preprocessor reads <var>infile</var> together with any
  78. other files it specifies with &lsquo;<samp>#include</samp>&rsquo;. All the output generated
  79. by the combined input files is written in <var>outfile</var>.
  80. </p>
  81. <p>Either <var>infile</var> or <var>outfile</var> may be <samp>-</samp>, which as
  82. <var>infile</var> means to read from standard input and as <var>outfile</var>
  83. means to write to standard output. If either file is omitted, it
  84. means the same as if <samp>-</samp> had been specified for that file.
  85. You can also use the <samp>-o <var>outfile</var></samp> option to specify the
  86. output file.
  87. </p>
  88. <p>Unless otherwise noted, or the option ends in &lsquo;<samp>=</samp>&rsquo;, all options
  89. which take an argument may have that argument appear either immediately
  90. after the option, or with a space between option and argument:
  91. <samp>-Ifoo</samp> and <samp>-I foo</samp> have the same effect.
  92. </p>
  93. <span id="index-grouping-options"></span>
  94. <span id="index-options_002c-grouping"></span>
  95. <p>Many options have multi-letter names; therefore multiple single-letter
  96. options may <em>not</em> be grouped: <samp>-dM</samp> is very different from
  97. &lsquo;<samp><span class="nolinebreak">-d</span>&nbsp;<span class="nolinebreak">-M</span></samp>&rsquo;<!-- /@w -->.
  98. </p>
  99. <span id="index-options"></span>
  100. <dl compact="compact">
  101. <dd>
  102. <span id="index-D"></span>
  103. </dd>
  104. <dt><code>-D <var>name</var></code></dt>
  105. <dd><p>Predefine <var>name</var> as a macro, with definition <code>1</code>.
  106. </p>
  107. </dd>
  108. <dt><code>-D <var>name</var>=<var>definition</var></code></dt>
  109. <dd><p>The contents of <var>definition</var> are tokenized and processed as if
  110. they appeared during translation phase three in a &lsquo;<samp>#define</samp>&rsquo;
  111. directive. In particular, the definition is truncated by
  112. embedded newline characters.
  113. </p>
  114. <p>If you are invoking the preprocessor from a shell or shell-like
  115. program you may need to use the shell&rsquo;s quoting syntax to protect
  116. characters such as spaces that have a meaning in the shell syntax.
  117. </p>
  118. <p>If you wish to define a function-like macro on the command line, write
  119. its argument list with surrounding parentheses before the equals sign
  120. (if any). Parentheses are meaningful to most shells, so you should
  121. quote the option. With <code>sh</code> and <code>csh</code>,
  122. <samp>-D'<var>name</var>(<var>args&hellip;</var>)=<var>definition</var>'</samp> works.
  123. </p>
  124. <p><samp>-D</samp> and <samp>-U</samp> options are processed in the order they
  125. are given on the command line. All <samp>-imacros <var>file</var></samp> and
  126. <samp>-include <var>file</var></samp> options are processed after all
  127. <samp>-D</samp> and <samp>-U</samp> options.
  128. </p>
  129. <span id="index-U"></span>
  130. </dd>
  131. <dt><code>-U <var>name</var></code></dt>
  132. <dd><p>Cancel any previous definition of <var>name</var>, either built in or
  133. provided with a <samp>-D</samp> option.
  134. </p>
  135. <span id="index-include"></span>
  136. </dd>
  137. <dt><code>-include <var>file</var></code></dt>
  138. <dd><p>Process <var>file</var> as if <code>#include &quot;file&quot;</code> appeared as the first
  139. line of the primary source file. However, the first directory searched
  140. for <var>file</var> is the preprocessor&rsquo;s working directory <em>instead of</em>
  141. the directory containing the main source file. If not found there, it
  142. is searched for in the remainder of the <code>#include &quot;&hellip;&quot;</code> search
  143. chain as normal.
  144. </p>
  145. <p>If multiple <samp>-include</samp> options are given, the files are included
  146. in the order they appear on the command line.
  147. </p>
  148. <span id="index-imacros"></span>
  149. </dd>
  150. <dt><code>-imacros <var>file</var></code></dt>
  151. <dd><p>Exactly like <samp>-include</samp>, except that any output produced by
  152. scanning <var>file</var> is thrown away. Macros it defines remain defined.
  153. This allows you to acquire all the macros from a header without also
  154. processing its declarations.
  155. </p>
  156. <p>All files specified by <samp>-imacros</samp> are processed before all files
  157. specified by <samp>-include</samp>.
  158. </p>
  159. <span id="index-undef"></span>
  160. </dd>
  161. <dt><code>-undef</code></dt>
  162. <dd><p>Do not predefine any system-specific or GCC-specific macros. The
  163. standard predefined macros remain defined.
  164. See <a href="Standard-Predefined-Macros.html">Standard Predefined Macros</a>.
  165. </p>
  166. <span id="index-pthread"></span>
  167. </dd>
  168. <dt><code>-pthread</code></dt>
  169. <dd><p>Define additional macros required for using the POSIX threads library.
  170. You should use this option consistently for both compilation and linking.
  171. This option is supported on GNU/Linux targets, most other Unix derivatives,
  172. and also on x86 Cygwin and MinGW targets.
  173. </p>
  174. <span id="index-M"></span>
  175. <span id="index-make"></span>
  176. <span id="index-dependencies_002c-make"></span>
  177. </dd>
  178. <dt><code>-M</code></dt>
  179. <dd><p>Instead of outputting the result of preprocessing, output a rule
  180. suitable for <code>make</code> describing the dependencies of the main
  181. source file. The preprocessor outputs one <code>make</code> rule containing
  182. the object file name for that source file, a colon, and the names of all
  183. the included files, including those coming from <samp>-include</samp> or
  184. <samp>-imacros</samp> command-line options.
  185. </p>
  186. <p>Unless specified explicitly (with <samp>-MT</samp> or <samp>-MQ</samp>), the
  187. object file name consists of the name of the source file with any
  188. suffix replaced with object file suffix and with any leading directory
  189. parts removed. If there are many included files then the rule is
  190. split into several lines using &lsquo;<samp>\</samp>&rsquo;-newline. The rule has no
  191. commands.
  192. </p>
  193. <p>This option does not suppress the preprocessor&rsquo;s debug output, such as
  194. <samp>-dM</samp>. To avoid mixing such debug output with the dependency
  195. rules you should explicitly specify the dependency output file with
  196. <samp>-MF</samp>, or use an environment variable like
  197. <code>DEPENDENCIES_OUTPUT</code> (see <a href="Environment-Variables.html">Environment Variables</a>). Debug output
  198. is still sent to the regular output stream as normal.
  199. </p>
  200. <p>Passing <samp>-M</samp> to the driver implies <samp>-E</samp>, and suppresses
  201. warnings with an implicit <samp>-w</samp>.
  202. </p>
  203. <span id="index-MM"></span>
  204. </dd>
  205. <dt><code>-MM</code></dt>
  206. <dd><p>Like <samp>-M</samp> but do not mention header files that are found in
  207. system header directories, nor header files that are included,
  208. directly or indirectly, from such a header.
  209. </p>
  210. <p>This implies that the choice of angle brackets or double quotes in an
  211. &lsquo;<samp>#include</samp>&rsquo; directive does not in itself determine whether that
  212. header appears in <samp>-MM</samp> dependency output.
  213. </p>
  214. <span id="dashMF"></span><span id="index-MF"></span>
  215. </dd>
  216. <dt><code>-MF <var>file</var></code></dt>
  217. <dd><p>When used with <samp>-M</samp> or <samp>-MM</samp>, specifies a
  218. file to write the dependencies to. If no <samp>-MF</samp> switch is given
  219. the preprocessor sends the rules to the same place it would send
  220. preprocessed output.
  221. </p>
  222. <p>When used with the driver options <samp>-MD</samp> or <samp>-MMD</samp>,
  223. <samp>-MF</samp> overrides the default dependency output file.
  224. </p>
  225. <p>If <var>file</var> is <samp>-</samp>, then the dependencies are written to <samp>stdout</samp>.
  226. </p>
  227. <span id="index-MG"></span>
  228. </dd>
  229. <dt><code>-MG</code></dt>
  230. <dd><p>In conjunction with an option such as <samp>-M</samp> requesting
  231. dependency generation, <samp>-MG</samp> assumes missing header files are
  232. generated files and adds them to the dependency list without raising
  233. an error. The dependency filename is taken directly from the
  234. <code>#include</code> directive without prepending any path. <samp>-MG</samp>
  235. also suppresses preprocessed output, as a missing header file renders
  236. this useless.
  237. </p>
  238. <p>This feature is used in automatic updating of makefiles.
  239. </p>
  240. <span id="index-Mno_002dmodules"></span>
  241. </dd>
  242. <dt><code>-Mno-modules</code></dt>
  243. <dd><p>Disable dependency generation for compiled module interfaces.
  244. </p>
  245. <span id="index-MP"></span>
  246. </dd>
  247. <dt><code>-MP</code></dt>
  248. <dd><p>This option instructs CPP to add a phony target for each dependency
  249. other than the main file, causing each to depend on nothing. These
  250. dummy rules work around errors <code>make</code> gives if you remove header
  251. files without updating the <samp>Makefile</samp> to match.
  252. </p>
  253. <p>This is typical output:
  254. </p>
  255. <div class="example">
  256. <pre class="example">test.o: test.c test.h
  257. test.h:
  258. </pre></div>
  259. <span id="index-MT"></span>
  260. </dd>
  261. <dt><code>-MT <var>target</var></code></dt>
  262. <dd>
  263. <p>Change the target of the rule emitted by dependency generation. By
  264. default CPP takes the name of the main input file, deletes any
  265. directory components and any file suffix such as &lsquo;<samp>.c</samp>&rsquo;, and
  266. appends the platform&rsquo;s usual object suffix. The result is the target.
  267. </p>
  268. <p>An <samp>-MT</samp> option sets the target to be exactly the string you
  269. specify. If you want multiple targets, you can specify them as a single
  270. argument to <samp>-MT</samp>, or use multiple <samp>-MT</samp> options.
  271. </p>
  272. <p>For example, <samp><span class="nolinebreak">-MT</span>&nbsp;'$(objpfx)foo.o'<!-- /@w --></samp> might give
  273. </p>
  274. <div class="example">
  275. <pre class="example">$(objpfx)foo.o: foo.c
  276. </pre></div>
  277. <span id="index-MQ"></span>
  278. </dd>
  279. <dt><code>-MQ <var>target</var></code></dt>
  280. <dd>
  281. <p>Same as <samp>-MT</samp>, but it quotes any characters which are special to
  282. Make. <samp><span class="nolinebreak">-MQ</span>&nbsp;'$(objpfx)foo.o'<!-- /@w --></samp> gives
  283. </p>
  284. <div class="example">
  285. <pre class="example">$$(objpfx)foo.o: foo.c
  286. </pre></div>
  287. <p>The default target is automatically quoted, as if it were given with
  288. <samp>-MQ</samp>.
  289. </p>
  290. <span id="index-MD"></span>
  291. </dd>
  292. <dt><code>-MD</code></dt>
  293. <dd><p><samp>-MD</samp> is equivalent to <samp>-M -MF <var>file</var></samp>, except that
  294. <samp>-E</samp> is not implied. The driver determines <var>file</var> based on
  295. whether an <samp>-o</samp> option is given. If it is, the driver uses its
  296. argument but with a suffix of <samp>.d</samp>, otherwise it takes the name
  297. of the input file, removes any directory components and suffix, and
  298. applies a <samp>.d</samp> suffix.
  299. </p>
  300. <p>If <samp>-MD</samp> is used in conjunction with <samp>-E</samp>, any
  301. <samp>-o</samp> switch is understood to specify the dependency output file
  302. (see <a href="#dashMF">-MF</a>), but if used without <samp>-E</samp>, each <samp>-o</samp>
  303. is understood to specify a target object file.
  304. </p>
  305. <p>Since <samp>-E</samp> is not implied, <samp>-MD</samp> can be used to generate
  306. a dependency output file as a side effect of the compilation process.
  307. </p>
  308. <span id="index-MMD"></span>
  309. </dd>
  310. <dt><code>-MMD</code></dt>
  311. <dd><p>Like <samp>-MD</samp> except mention only user header files, not system
  312. header files.
  313. </p>
  314. <span id="index-fpreprocessed"></span>
  315. </dd>
  316. <dt><code>-fpreprocessed</code></dt>
  317. <dd><p>Indicate to the preprocessor that the input file has already been
  318. preprocessed. This suppresses things like macro expansion, trigraph
  319. conversion, escaped newline splicing, and processing of most directives.
  320. The preprocessor still recognizes and removes comments, so that you can
  321. pass a file preprocessed with <samp>-C</samp> to the compiler without
  322. problems. In this mode the integrated preprocessor is little more than
  323. a tokenizer for the front ends.
  324. </p>
  325. <p><samp>-fpreprocessed</samp> is implicit if the input file has one of the
  326. extensions &lsquo;<samp>.i</samp>&rsquo;, &lsquo;<samp>.ii</samp>&rsquo; or &lsquo;<samp>.mi</samp>&rsquo;. These are the
  327. extensions that GCC uses for preprocessed files created by
  328. <samp>-save-temps</samp>.
  329. </p>
  330. <span id="index-fdirectives_002donly"></span>
  331. </dd>
  332. <dt><code>-fdirectives-only</code></dt>
  333. <dd><p>When preprocessing, handle directives, but do not expand macros.
  334. </p>
  335. <p>The option&rsquo;s behavior depends on the <samp>-E</samp> and <samp>-fpreprocessed</samp>
  336. options.
  337. </p>
  338. <p>With <samp>-E</samp>, preprocessing is limited to the handling of directives
  339. such as <code>#define</code>, <code>#ifdef</code>, and <code>#error</code>. Other
  340. preprocessor operations, such as macro expansion and trigraph
  341. conversion are not performed. In addition, the <samp>-dD</samp> option is
  342. implicitly enabled.
  343. </p>
  344. <p>With <samp>-fpreprocessed</samp>, predefinition of command line and most
  345. builtin macros is disabled. Macros such as <code>__LINE__</code>, which are
  346. contextually dependent, are handled normally. This enables compilation of
  347. files previously preprocessed with <code>-E -fdirectives-only</code>.
  348. </p>
  349. <p>With both <samp>-E</samp> and <samp>-fpreprocessed</samp>, the rules for
  350. <samp>-fpreprocessed</samp> take precedence. This enables full preprocessing of
  351. files previously preprocessed with <code>-E -fdirectives-only</code>.
  352. </p>
  353. <span id="index-fdollars_002din_002didentifiers"></span>
  354. </dd>
  355. <dt><code>-fdollars-in-identifiers</code></dt>
  356. <dd><span id="fdollars_002din_002didentifiers"></span><p>Accept &lsquo;<samp>$</samp>&rsquo; in identifiers.
  357. See <a href="Implementation_002ddefined-behavior.html#Identifier-characters">Identifier characters</a>.
  358. </p>
  359. <span id="index-fextended_002didentifiers"></span>
  360. </dd>
  361. <dt><code>-fextended-identifiers</code></dt>
  362. <dd><p>Accept universal character names and extended characters in
  363. identifiers. This option is enabled by default for C99 (and later C
  364. standard versions) and C++.
  365. </p>
  366. <span id="index-fno_002dcanonical_002dsystem_002dheaders"></span>
  367. </dd>
  368. <dt><code>-fno-canonical-system-headers</code></dt>
  369. <dd><p>When preprocessing, do not shorten system header paths with canonicalization.
  370. </p>
  371. <span id="index-fmax_002dinclude_002ddepth"></span>
  372. </dd>
  373. <dt><code>-fmax-include-depth=<var>depth</var></code></dt>
  374. <dd><p>Set the maximum depth of the nested #include. The default is 200.
  375. </p>
  376. <span id="index-ftabstop"></span>
  377. </dd>
  378. <dt><code>-ftabstop=<var>width</var></code></dt>
  379. <dd><p>Set the distance between tab stops. This helps the preprocessor report
  380. correct column numbers in warnings or errors, even if tabs appear on the
  381. line. If the value is less than 1 or greater than 100, the option is
  382. ignored. The default is 8.
  383. </p>
  384. <span id="index-ftrack_002dmacro_002dexpansion"></span>
  385. </dd>
  386. <dt><code>-ftrack-macro-expansion<span class="roman">[</span>=<var>level</var><span class="roman">]</span></code></dt>
  387. <dd><p>Track locations of tokens across macro expansions. This allows the
  388. compiler to emit diagnostic about the current macro expansion stack
  389. when a compilation error occurs in a macro expansion. Using this
  390. option makes the preprocessor and the compiler consume more
  391. memory. The <var>level</var> parameter can be used to choose the level of
  392. precision of token location tracking thus decreasing the memory
  393. consumption if necessary. Value &lsquo;<samp>0</samp>&rsquo; of <var>level</var> de-activates
  394. this option. Value &lsquo;<samp>1</samp>&rsquo; tracks tokens locations in a
  395. degraded mode for the sake of minimal memory overhead. In this mode
  396. all tokens resulting from the expansion of an argument of a
  397. function-like macro have the same location. Value &lsquo;<samp>2</samp>&rsquo; tracks
  398. tokens locations completely. This value is the most memory hungry.
  399. When this option is given no argument, the default parameter value is
  400. &lsquo;<samp>2</samp>&rsquo;.
  401. </p>
  402. <p>Note that <code>-ftrack-macro-expansion=2</code> is activated by default.
  403. </p>
  404. <span id="index-fmacro_002dprefix_002dmap"></span>
  405. </dd>
  406. <dt><code>-fmacro-prefix-map=<var>old</var>=<var>new</var></code></dt>
  407. <dd><p>When preprocessing files residing in directory <samp><var>old</var></samp>,
  408. expand the <code>__FILE__</code> and <code>__BASE_FILE__</code> macros as if the
  409. files resided in directory <samp><var>new</var></samp> instead. This can be used
  410. to change an absolute path to a relative path by using <samp>.</samp> for
  411. <var>new</var> which can result in more reproducible builds that are
  412. location independent. This option also affects
  413. <code>__builtin_FILE()</code> during compilation. See also
  414. <samp>-ffile-prefix-map</samp> and <samp>-fcanon-prefix-map</samp>.
  415. </p>
  416. <span id="index-fexec_002dcharset"></span>
  417. <span id="index-character-set_002c-execution"></span>
  418. </dd>
  419. <dt><code>-fexec-charset=<var>charset</var></code></dt>
  420. <dd><p>Set the execution character set, used for string and character
  421. constants. The default is UTF-8. <var>charset</var> can be any encoding
  422. supported by the system&rsquo;s <code>iconv</code> library routine.
  423. </p>
  424. <span id="index-fwide_002dexec_002dcharset"></span>
  425. <span id="index-character-set_002c-wide-execution"></span>
  426. </dd>
  427. <dt><code>-fwide-exec-charset=<var>charset</var></code></dt>
  428. <dd><p>Set the wide execution character set, used for wide string and
  429. character constants. The default is one of UTF-32BE, UTF-32LE, UTF-16BE,
  430. or UTF-16LE, whichever corresponds to the width of <code>wchar_t</code> and the
  431. big-endian or little-endian byte order being used for code generation. As
  432. with <samp>-fexec-charset</samp>, <var>charset</var> can be any encoding supported
  433. by the system&rsquo;s <code>iconv</code> library routine; however, you will have
  434. problems with encodings that do not fit exactly in <code>wchar_t</code>.
  435. </p>
  436. <span id="index-finput_002dcharset"></span>
  437. <span id="index-character-set_002c-input"></span>
  438. </dd>
  439. <dt><code>-finput-charset=<var>charset</var></code></dt>
  440. <dd><p>Set the input character set, used for translation from the character
  441. set of the input file to the source character set used by GCC. If the
  442. locale does not specify, or GCC cannot get this information from the
  443. locale, the default is UTF-8. This can be overridden by either the locale
  444. or this command-line option. Currently the command-line option takes
  445. precedence if there&rsquo;s a conflict. <var>charset</var> can be any encoding
  446. supported by the system&rsquo;s <code>iconv</code> library routine.
  447. </p>
  448. <span id="index-fworking_002ddirectory"></span>
  449. <span id="index-fno_002dworking_002ddirectory"></span>
  450. </dd>
  451. <dt><code>-fworking-directory</code></dt>
  452. <dd><p>Enable generation of linemarkers in the preprocessor output that
  453. let the compiler know the current working directory at the time of
  454. preprocessing. When this option is enabled, the preprocessor
  455. emits, after the initial linemarker, a second linemarker with the
  456. current working directory followed by two slashes. GCC uses this
  457. directory, when it&rsquo;s present in the preprocessed input, as the
  458. directory emitted as the current working directory in some debugging
  459. information formats. This option is implicitly enabled if debugging
  460. information is enabled, but this can be inhibited with the negated
  461. form <samp>-fno-working-directory</samp>. If the <samp>-P</samp> flag is
  462. present in the command line, this option has no effect, since no
  463. <code>#line</code> directives are emitted whatsoever.
  464. </p>
  465. <span id="index-A"></span>
  466. </dd>
  467. <dt><code>-A <var>predicate</var>=<var>answer</var></code></dt>
  468. <dd><p>Make an assertion with the predicate <var>predicate</var> and answer
  469. <var>answer</var>. This form is preferred to the older form <samp>-A
  470. <var>predicate</var>(<var>answer</var>)</samp>, which is still supported, because
  471. it does not use shell special characters.
  472. See <a href="Obsolete-Features.html">Obsolete Features</a>.
  473. </p>
  474. </dd>
  475. <dt><code>-A -<var>predicate</var>=<var>answer</var></code></dt>
  476. <dd><p>Cancel an assertion with the predicate <var>predicate</var> and answer
  477. <var>answer</var>.
  478. </p>
  479. <span id="index-C"></span>
  480. </dd>
  481. <dt><code>-C</code></dt>
  482. <dd><p>Do not discard comments. All comments are passed through to the output
  483. file, except for comments in processed directives, which are deleted
  484. along with the directive.
  485. </p>
  486. <p>You should be prepared for side effects when using <samp>-C</samp>; it
  487. causes the preprocessor to treat comments as tokens in their own right.
  488. For example, comments appearing at the start of what would be a
  489. directive line have the effect of turning that line into an ordinary
  490. source line, since the first token on the line is no longer a &lsquo;<samp>#</samp>&rsquo;.
  491. </p>
  492. <span id="index-CC"></span>
  493. </dd>
  494. <dt><code>-CC</code></dt>
  495. <dd><p>Do not discard comments, including during macro expansion. This is
  496. like <samp>-C</samp>, except that comments contained within macros are
  497. also passed through to the output file where the macro is expanded.
  498. </p>
  499. <p>In addition to the side effects of the <samp>-C</samp> option, the
  500. <samp>-CC</samp> option causes all C++-style comments inside a macro
  501. to be converted to C-style comments. This is to prevent later use
  502. of that macro from inadvertently commenting out the remainder of
  503. the source line.
  504. </p>
  505. <p>The <samp>-CC</samp> option is generally used to support lint comments.
  506. </p>
  507. <span id="index-P"></span>
  508. </dd>
  509. <dt><code>-P</code></dt>
  510. <dd><p>Inhibit generation of linemarkers in the output from the preprocessor.
  511. This might be useful when running the preprocessor on something that is
  512. not C code, and will be sent to a program which might be confused by the
  513. linemarkers.
  514. See <a href="Preprocessor-Output.html">Preprocessor Output</a>.
  515. </p>
  516. <span id="index-traditional-C-language"></span>
  517. <span id="index-C-language_002c-traditional"></span>
  518. <span id="index-traditional_002dcpp"></span>
  519. <span id="index-traditional"></span>
  520. </dd>
  521. <dt><code>-traditional</code></dt>
  522. <dt><code>-traditional-cpp</code></dt>
  523. <dd>
  524. <p>Try to imitate the behavior of pre-standard C preprocessors, as
  525. opposed to ISO C preprocessors.
  526. See <a href="Traditional-Mode.html">Traditional Mode</a>.
  527. </p>
  528. <p>Note that GCC does not otherwise attempt to emulate a pre-standard
  529. C compiler, and these options are only supported with the <samp>-E</samp>
  530. switch, or when invoking CPP explicitly.
  531. </p>
  532. <span id="index-trigraphs-1"></span>
  533. </dd>
  534. <dt><code>-trigraphs</code></dt>
  535. <dd><p>Support ISO C trigraphs.
  536. These are three-character sequences, all starting with &lsquo;<samp>??</samp>&rsquo;, that
  537. are defined by ISO C to stand for single characters. For example,
  538. &lsquo;<samp>??/</samp>&rsquo; stands for &lsquo;<samp>\</samp>&rsquo;, so &lsquo;<samp>'??/n'</samp>&rsquo; is a character
  539. constant for a newline.
  540. See <a href="Initial-processing.html">Initial processing</a>.
  541. </p>
  542. <p>By default, GCC ignores trigraphs, but in
  543. standard-conforming modes it converts them. See the <samp>-std</samp> and
  544. <samp>-ansi</samp> options.
  545. </p>
  546. <span id="index-remap"></span>
  547. </dd>
  548. <dt><code>-remap</code></dt>
  549. <dd><p>Enable special code to work around file systems which only permit very
  550. short file names, such as MS-DOS.
  551. </p>
  552. <span id="index-H"></span>
  553. </dd>
  554. <dt><code>-H</code></dt>
  555. <dd><p>Print the name of each header file used, in addition to other normal
  556. activities. Each name is indented to show how deep in the
  557. &lsquo;<samp>#include</samp>&rsquo; stack it is. Precompiled header files are also
  558. printed, even if they are found to be invalid; an invalid precompiled
  559. header file is printed with &lsquo;<samp>...x</samp>&rsquo; and a valid one with &lsquo;<samp>...!</samp>&rsquo; .
  560. </p>
  561. <span id="index-d"></span>
  562. </dd>
  563. <dt><code>-d<var>letters</var></code></dt>
  564. <dd><p>Says to make debugging dumps during compilation as specified by
  565. <var>letters</var>. The flags documented here are those relevant to the
  566. preprocessor. Other <var>letters</var> are interpreted
  567. by the compiler proper, or reserved for future versions of GCC, and so
  568. are silently ignored. If you specify <var>letters</var> whose behavior
  569. conflicts, the result is undefined.
  570. </p>
  571. <dl compact="compact">
  572. <dd><span id="index-dM"></span>
  573. </dd>
  574. <dt><code>-dM</code></dt>
  575. <dd><p>Instead of the normal output, generate a list of &lsquo;<samp>#define</samp>&rsquo;
  576. directives for all the macros defined during the execution of the
  577. preprocessor, including predefined macros. This gives you a way of
  578. finding out what is predefined in your version of the preprocessor.
  579. Assuming you have no file <samp>foo.h</samp>, the command
  580. </p>
  581. <div class="example">
  582. <pre class="example">touch foo.h; cpp -dM foo.h
  583. </pre></div>
  584. <p>shows all the predefined macros.
  585. </p>
  586. <span id="index-dD"></span>
  587. </dd>
  588. <dt><code>-dD</code></dt>
  589. <dd><p>Like <samp>-dM</samp> except in two respects: it does <em>not</em> include the
  590. predefined macros, and it outputs <em>both</em> the &lsquo;<samp>#define</samp>&rsquo;
  591. directives and the result of preprocessing. Both kinds of output go to
  592. the standard output file.
  593. </p>
  594. <span id="index-dN"></span>
  595. </dd>
  596. <dt><code>-dN</code></dt>
  597. <dd><p>Like <samp>-dD</samp>, but emit only the macro names, not their expansions.
  598. </p>
  599. <span id="index-dI"></span>
  600. </dd>
  601. <dt><code>-dI</code></dt>
  602. <dd><p>Output &lsquo;<samp>#include</samp>&rsquo; directives in addition to the result of
  603. preprocessing.
  604. </p>
  605. <span id="index-dU"></span>
  606. </dd>
  607. <dt><code>-dU</code></dt>
  608. <dd><p>Like <samp>-dD</samp> except that only macros that are expanded, or whose
  609. definedness is tested in preprocessor directives, are output; the
  610. output is delayed until the use or test of the macro; and
  611. &lsquo;<samp>#undef</samp>&rsquo; directives are also output for macros tested but
  612. undefined at the time.
  613. </p></dd>
  614. </dl>
  615. <span id="index-fdebug_002dcpp"></span>
  616. </dd>
  617. <dt><code>-fdebug-cpp</code></dt>
  618. <dd><p>This option is only useful for debugging GCC. When used from CPP or with
  619. <samp>-E</samp>, it dumps debugging information about location maps. Every
  620. token in the output is preceded by the dump of the map its location
  621. belongs to.
  622. </p>
  623. <p>When used from GCC without <samp>-E</samp>, this option has no effect.
  624. </p>
  625. <span id="index-I"></span>
  626. <span id="index-iquote"></span>
  627. <span id="index-isystem"></span>
  628. <span id="index-idirafter"></span>
  629. </dd>
  630. <dt><code>-I <var>dir</var></code></dt>
  631. <dt><code>-iquote <var>dir</var></code></dt>
  632. <dt><code>-isystem <var>dir</var></code></dt>
  633. <dt><code>-idirafter <var>dir</var></code></dt>
  634. <dd><p>Add the directory <var>dir</var> to the list of directories to be searched
  635. for header files during preprocessing.
  636. See <a href="Search-Path.html">Search Path</a>.
  637. If <var>dir</var> begins with &lsquo;<samp>=</samp>&rsquo; or <code>$SYSROOT</code>, then the &lsquo;<samp>=</samp>&rsquo;
  638. or <code>$SYSROOT</code> is replaced by the sysroot prefix; see
  639. <samp>--sysroot</samp> and <samp>-isysroot</samp>.
  640. </p>
  641. <p>Directories specified with <samp>-iquote</samp> apply only to the quote
  642. form of the directive, <code>#include&nbsp;&quot;<var>file</var>&quot;<!-- /@w --></code>.
  643. Directories specified with <samp>-I</samp>, <samp>-isystem</samp>,
  644. or <samp>-idirafter</samp> apply to lookup for both the
  645. <code>#include&nbsp;&quot;<var>file</var>&quot;<!-- /@w --></code> and
  646. <code>#include&nbsp;&lt;<var>file</var>&gt;<!-- /@w --></code> directives.
  647. </p>
  648. <p>You can specify any number or combination of these options on the
  649. command line to search for header files in several directories.
  650. The lookup order is as follows:
  651. </p>
  652. <ol>
  653. <li> For the quote form of the include directive, the directory of the current
  654. file is searched first.
  655. </li><li> For the quote form of the include directive, the directories specified
  656. by <samp>-iquote</samp> options are searched in left-to-right order,
  657. as they appear on the command line.
  658. </li><li> Directories specified with <samp>-I</samp> options are scanned in
  659. left-to-right order.
  660. </li><li> Directories specified with <samp>-isystem</samp> options are scanned in
  661. left-to-right order.
  662. </li><li> Standard system directories are scanned.
  663. </li><li> Directories specified with <samp>-idirafter</samp> options are scanned in
  664. left-to-right order.
  665. </li></ol>
  666. <p>You can use <samp>-I</samp> to override a system header
  667. file, substituting your own version, since these directories are
  668. searched before the standard system header file directories.
  669. However, you should
  670. not use this option to add directories that contain vendor-supplied
  671. system header files; use <samp>-isystem</samp> for that.
  672. </p>
  673. <p>The <samp>-isystem</samp> and <samp>-idirafter</samp> options also mark the directory
  674. as a system directory, so that it gets the same special treatment that
  675. is applied to the standard system directories.
  676. See <a href="System-Headers.html">System Headers</a>.
  677. </p>
  678. <p>If a standard system include directory, or a directory specified with
  679. <samp>-isystem</samp>, is also specified with <samp>-I</samp>, the <samp>-I</samp>
  680. option is ignored. The directory is still searched but as a
  681. system directory at its normal position in the system include chain.
  682. This is to ensure that GCC&rsquo;s procedure to fix buggy system headers and
  683. the ordering for the <code>#include_next</code> directive are not inadvertently
  684. changed.
  685. If you really need to change the search order for system directories,
  686. use the <samp>-nostdinc</samp> and/or <samp>-isystem</samp> options.
  687. See <a href="System-Headers.html">System Headers</a>.
  688. </p>
  689. <span id="index-I_002d"></span>
  690. </dd>
  691. <dt><code>-I-</code></dt>
  692. <dd><p>Split the include path.
  693. This option has been deprecated. Please use <samp>-iquote</samp> instead for
  694. <samp>-I</samp> directories before the <samp>-I-</samp> and remove the <samp>-I-</samp>
  695. option.
  696. </p>
  697. <p>Any directories specified with <samp>-I</samp>
  698. options before <samp>-I-</samp> are searched only for headers requested with
  699. <code>#include&nbsp;&quot;<var>file</var>&quot;<!-- /@w --></code>; they are not searched for
  700. <code>#include&nbsp;&lt;<var>file</var>&gt;<!-- /@w --></code>. If additional directories are
  701. specified with <samp>-I</samp> options after the <samp>-I-</samp>, those
  702. directories are searched for all &lsquo;<samp>#include</samp>&rsquo; directives.
  703. </p>
  704. <p>In addition, <samp>-I-</samp> inhibits the use of the directory of the current
  705. file directory as the first search directory for <code>#include&nbsp;&quot;<var>file</var>&quot;<!-- /@w --></code>. There is no way to override this effect of <samp>-I-</samp>.
  706. See <a href="Search-Path.html">Search Path</a>.
  707. </p>
  708. <span id="index-iprefix"></span>
  709. </dd>
  710. <dt><code>-iprefix <var>prefix</var></code></dt>
  711. <dd><p>Specify <var>prefix</var> as the prefix for subsequent <samp>-iwithprefix</samp>
  712. options. If the prefix represents a directory, you should include the
  713. final &lsquo;<samp>/</samp>&rsquo;.
  714. </p>
  715. <span id="index-iwithprefix"></span>
  716. <span id="index-iwithprefixbefore"></span>
  717. </dd>
  718. <dt><code>-iwithprefix <var>dir</var></code></dt>
  719. <dt><code>-iwithprefixbefore <var>dir</var></code></dt>
  720. <dd><p>Append <var>dir</var> to the prefix specified previously with
  721. <samp>-iprefix</samp>, and add the resulting directory to the include search
  722. path. <samp>-iwithprefixbefore</samp> puts it in the same place <samp>-I</samp>
  723. would; <samp>-iwithprefix</samp> puts it where <samp>-idirafter</samp> would.
  724. </p>
  725. <span id="index-isysroot"></span>
  726. </dd>
  727. <dt><code>-isysroot <var>dir</var></code></dt>
  728. <dd><p>This option is like the <samp>--sysroot</samp> option, but applies only to
  729. header files (except for Darwin targets, where it applies to both header
  730. files and libraries). See the <samp>--sysroot</samp> option for more
  731. information.
  732. </p>
  733. <span id="index-imultilib"></span>
  734. </dd>
  735. <dt><code>-imultilib <var>dir</var></code></dt>
  736. <dd><p>Use <var>dir</var> as a subdirectory of the directory containing
  737. target-specific C++ headers.
  738. </p>
  739. <span id="index-nostdinc"></span>
  740. </dd>
  741. <dt><code>-nostdinc</code></dt>
  742. <dd><p>Do not search the standard system directories for header files.
  743. Only the directories explicitly specified with <samp>-I</samp>,
  744. <samp>-iquote</samp>, <samp>-isystem</samp>, and/or <samp>-idirafter</samp>
  745. options (and the directory of the current file, if appropriate)
  746. are searched.
  747. </p>
  748. <span id="index-nostdinc_002b_002b"></span>
  749. </dd>
  750. <dt><code>-nostdinc++</code></dt>
  751. <dd><p>Do not search for header files in the C++-specific standard directories,
  752. but do still search the other standard directories. (This option is
  753. used when building the C++ library.)
  754. </p>
  755. <span id="index-Wcomment"></span>
  756. <span id="index-Wcomments"></span>
  757. </dd>
  758. <dt><code>-Wcomment</code></dt>
  759. <dt><code>-Wcomments</code></dt>
  760. <dd><p>Warn whenever a comment-start sequence &lsquo;<samp>/*</samp>&rsquo; appears in a &lsquo;<samp>/*</samp>&rsquo;
  761. comment, or whenever a backslash-newline appears in a &lsquo;<samp>//</samp>&rsquo; comment.
  762. This warning is enabled by <samp>-Wall</samp>.
  763. </p>
  764. <span id="index-Wtrigraphs"></span>
  765. </dd>
  766. <dt><code>-Wtrigraphs</code></dt>
  767. <dd><span id="Wtrigraphs"></span><p>Warn if any trigraphs are encountered that might change the meaning of
  768. the program. Trigraphs within comments are not warned about,
  769. except those that would form escaped newlines.
  770. </p>
  771. <p>This option is implied by <samp>-Wall</samp>. If <samp>-Wall</samp> is not
  772. given, this option is still enabled unless trigraphs are enabled. To
  773. get trigraph conversion without warnings, but get the other
  774. <samp>-Wall</samp> warnings, use &lsquo;<samp>-trigraphs -Wall -Wno-trigraphs</samp>&rsquo;.
  775. </p>
  776. <span id="index-Wundef"></span>
  777. <span id="index-Wno_002dundef"></span>
  778. </dd>
  779. <dt><code>-Wundef</code></dt>
  780. <dd><p>Warn if an undefined identifier is evaluated in an <code>#if</code> directive.
  781. Such identifiers are replaced with zero.
  782. </p>
  783. <span id="index-Wexpansion_002dto_002ddefined"></span>
  784. </dd>
  785. <dt><code>-Wexpansion-to-defined</code></dt>
  786. <dd><p>Warn whenever &lsquo;<samp>defined</samp>&rsquo; is encountered in the expansion of a macro
  787. (including the case where the macro is expanded by an &lsquo;<samp>#if</samp>&rsquo; directive).
  788. Such usage is not portable.
  789. This warning is also enabled by <samp>-Wpedantic</samp> and <samp>-Wextra</samp>.
  790. </p>
  791. <span id="index-Wunused_002dmacros"></span>
  792. </dd>
  793. <dt><code>-Wunused-macros</code></dt>
  794. <dd><p>Warn about macros defined in the main file that are unused. A macro
  795. is <em>used</em> if it is expanded or tested for existence at least once.
  796. The preprocessor also warns if the macro has not been used at the
  797. time it is redefined or undefined.
  798. </p>
  799. <p>Built-in macros, macros defined on the command line, and macros
  800. defined in include files are not warned about.
  801. </p>
  802. <p><em>Note:</em> If a macro is actually used, but only used in skipped
  803. conditional blocks, then the preprocessor reports it as unused. To avoid the
  804. warning in such a case, you might improve the scope of the macro&rsquo;s
  805. definition by, for example, moving it into the first skipped block.
  806. Alternatively, you could provide a dummy use with something like:
  807. </p>
  808. <div class="example">
  809. <pre class="example">#if defined the_macro_causing_the_warning
  810. #endif
  811. </pre></div>
  812. <span id="index-Wno_002dendif_002dlabels"></span>
  813. <span id="index-Wendif_002dlabels"></span>
  814. </dd>
  815. <dt><code>-Wno-endif-labels</code></dt>
  816. <dd><p>Do not warn whenever an <code>#else</code> or an <code>#endif</code> are followed by text.
  817. This sometimes happens in older programs with code of the form
  818. </p>
  819. <div class="example">
  820. <pre class="example">#if FOO
  821. &hellip;
  822. #else FOO
  823. &hellip;
  824. #endif FOO
  825. </pre></div>
  826. <p>The second and third <code>FOO</code> should be in comments.
  827. This warning is on by default.
  828. </p></dd>
  829. </dl>
  830. <hr>
  831. <div class="header">
  832. <p>
  833. Next: <a href="Environment-Variables.html" accesskey="n" rel="next">Environment Variables</a>, Previous: <a href="Implementation-Details.html" accesskey="p" rel="prev">Implementation Details</a>, Up: <a href="index.html" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html" title="Index" rel="index">Index</a>]</p>
  834. </div>
  835. </body>
  836. </html>