You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

878 lines
38KB

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