Preprocessing-Options.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1999-2017 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; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  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 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>The GNU Fortran Compiler: Preprocessing Options</title>
  20. <meta name="description" content="The GNU Fortran Compiler: Preprocessing Options">
  21. <meta name="keywords" content="The GNU Fortran Compiler: Preprocessing Options">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran" rel="up" title="Invoking GNU Fortran">
  30. <link href="Error-and-Warning-Options.html#Error-and-Warning-Options" rel="next" title="Error and Warning Options">
  31. <link href="Fortran-Dialect-Options.html#Fortran-Dialect-Options" rel="prev" title="Fortran Dialect Options">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Preprocessing-Options"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Error-and-Warning-Options.html#Error-and-Warning-Options" accesskey="n" rel="next">Error and Warning Options</a>, Previous: <a href="Fortran-Dialect-Options.html#Fortran-Dialect-Options" accesskey="p" rel="prev">Fortran Dialect Options</a>, Up: <a href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran" accesskey="u" rel="up">Invoking GNU Fortran</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="Enable-and-customize-preprocessing"></a>
  69. <h3 class="section">2.3 Enable and customize preprocessing</h3>
  70. <a name="index-preprocessor"></a>
  71. <a name="index-options_002c-preprocessor"></a>
  72. <a name="index-CPP-1"></a>
  73. <p>Preprocessor related options. See section
  74. <a href="Preprocessing-and-conditional-compilation.html#Preprocessing-and-conditional-compilation">Preprocessing and conditional compilation</a> for more detailed
  75. information on preprocessing in <code>gfortran</code>.
  76. </p>
  77. <dl compact="compact">
  78. <dt><code>-cpp</code></dt>
  79. <dt><code>-nocpp</code></dt>
  80. <dd><a name="index-cpp"></a>
  81. <a name="index-fpp"></a>
  82. <a name="index-preprocessor_002c-enable"></a>
  83. <a name="index-preprocessor_002c-disable"></a>
  84. <p>Enable preprocessing. The preprocessor is automatically invoked if
  85. the file extension is <samp>.fpp</samp>, <samp>.FPP</samp>, <samp>.F</samp>, <samp>.FOR</samp>,
  86. <samp>.FTN</samp>, <samp>.F90</samp>, <samp>.F95</samp>, <samp>.F03</samp> or <samp>.F08</samp>. Use
  87. this option to manually enable preprocessing of any kind of Fortran file.
  88. </p>
  89. <p>To disable preprocessing of files with any of the above listed extensions,
  90. use the negative form: <samp>-nocpp</samp>.
  91. </p>
  92. <p>The preprocessor is run in traditional mode. Any restrictions of the
  93. file-format, especially the limits on line length, apply for
  94. preprocessed output as well, so it might be advisable to use the
  95. <samp>-ffree-line-length-none</samp> or <samp>-ffixed-line-length-none</samp>
  96. options.
  97. </p>
  98. </dd>
  99. <dt><code>-dM</code></dt>
  100. <dd><a name="index-dM"></a>
  101. <a name="index-preprocessor_002c-debugging"></a>
  102. <a name="index-debugging_002c-preprocessor"></a>
  103. <p>Instead of the normal output, generate a list of <code>'#define'</code>
  104. directives for all the macros defined during the execution of the
  105. preprocessor, including predefined macros. This gives you a way
  106. of finding out what is predefined in your version of the preprocessor.
  107. Assuming you have no file <samp>foo.f90</samp>, the command
  108. </p><div class="smallexample">
  109. <pre class="smallexample"> touch foo.f90; gfortran -cpp -E -dM foo.f90
  110. </pre></div>
  111. <p>will show all the predefined macros.
  112. </p>
  113. </dd>
  114. <dt><code>-dD</code></dt>
  115. <dd><a name="index-dD"></a>
  116. <a name="index-preprocessor_002c-debugging-1"></a>
  117. <a name="index-debugging_002c-preprocessor-1"></a>
  118. <p>Like <samp>-dM</samp> except in two respects: it does not include the
  119. predefined macros, and it outputs both the <code>#define</code> directives
  120. and the result of preprocessing. Both kinds of output go to the
  121. standard output file.
  122. </p>
  123. </dd>
  124. <dt><code>-dN</code></dt>
  125. <dd><a name="index-dN"></a>
  126. <a name="index-preprocessor_002c-debugging-2"></a>
  127. <a name="index-debugging_002c-preprocessor-2"></a>
  128. <p>Like <samp>-dD</samp>, but emit only the macro names, not their expansions.
  129. </p>
  130. </dd>
  131. <dt><code>-dU</code></dt>
  132. <dd><a name="index-dU"></a>
  133. <a name="index-preprocessor_002c-debugging-3"></a>
  134. <a name="index-debugging_002c-preprocessor-3"></a>
  135. <p>Like <samp>dD</samp> except that only macros that are expanded, or whose
  136. definedness is tested in preprocessor directives, are output; the
  137. output is delayed until the use or test of the macro; and <code>'#undef'</code>
  138. directives are also output for macros tested but undefined at the time.
  139. </p>
  140. </dd>
  141. <dt><code>-dI</code></dt>
  142. <dd><a name="index-dI"></a>
  143. <a name="index-preprocessor_002c-debugging-4"></a>
  144. <a name="index-debugging_002c-preprocessor-4"></a>
  145. <p>Output <code>'#include'</code> directives in addition to the result
  146. of preprocessing.
  147. </p>
  148. </dd>
  149. <dt><code>-fworking-directory</code></dt>
  150. <dd><a name="index-fworking_002ddirectory"></a>
  151. <a name="index-preprocessor_002c-working-directory"></a>
  152. <p>Enable generation of linemarkers in the preprocessor output that will
  153. let the compiler know the current working directory at the time of
  154. preprocessing. When this option is enabled, the preprocessor will emit,
  155. after the initial linemarker, a second linemarker with the current
  156. working directory followed by two slashes. GCC will use this directory,
  157. when it is present in the preprocessed input, as the directory emitted
  158. as the current working directory in some debugging information formats.
  159. This option is implicitly enabled if debugging information is enabled,
  160. but this can be inhibited with the negated form
  161. <samp>-fno-working-directory</samp>. If the <samp>-P</samp> flag is present
  162. in the command line, this option has no effect, since no <code>#line</code>
  163. directives are emitted whatsoever.
  164. </p>
  165. </dd>
  166. <dt><code>-idirafter <var>dir</var></code></dt>
  167. <dd><a name="index-idirafter-dir"></a>
  168. <a name="index-preprocessing_002c-include-path"></a>
  169. <p>Search <var>dir</var> for include files, but do it after all directories
  170. specified with <samp>-I</samp> and the standard system directories have
  171. been exhausted. <var>dir</var> is treated as a system include directory.
  172. If dir begins with <code>=</code>, then the <code>=</code> will be replaced by
  173. the sysroot prefix; see <samp>--sysroot</samp> and <samp>-isysroot</samp>.
  174. </p>
  175. </dd>
  176. <dt><code>-imultilib <var>dir</var></code></dt>
  177. <dd><a name="index-imultilib-dir"></a>
  178. <a name="index-preprocessing_002c-include-path-1"></a>
  179. <p>Use <var>dir</var> as a subdirectory of the directory containing target-specific
  180. C++ headers.
  181. </p>
  182. </dd>
  183. <dt><code>-iprefix <var>prefix</var></code></dt>
  184. <dd><a name="index-iprefix-prefix"></a>
  185. <a name="index-preprocessing_002c-include-path-2"></a>
  186. <p>Specify <var>prefix</var> as the prefix for subsequent <samp>-iwithprefix</samp>
  187. options. If the <var>prefix</var> represents a directory, you should include
  188. the final <code>'/'</code>.
  189. </p>
  190. </dd>
  191. <dt><code>-isysroot <var>dir</var></code></dt>
  192. <dd><a name="index-isysroot-dir"></a>
  193. <a name="index-preprocessing_002c-include-path-3"></a>
  194. <p>This option is like the <samp>--sysroot</samp> option, but applies only to
  195. header files. See the <samp>--sysroot</samp> option for more information.
  196. </p>
  197. </dd>
  198. <dt><code>-iquote <var>dir</var></code></dt>
  199. <dd><a name="index-iquote-dir"></a>
  200. <a name="index-preprocessing_002c-include-path-4"></a>
  201. <p>Search <var>dir</var> only for header files requested with <code>#include &quot;file&quot;</code>;
  202. they are not searched for <code>#include &lt;file&gt;</code>, before all directories
  203. specified by <samp>-I</samp> and before the standard system directories. If
  204. <var>dir</var> begins with <code>=</code>, then the <code>=</code> will be replaced by the
  205. sysroot prefix; see <samp>--sysroot</samp> and <samp>-isysroot</samp>.
  206. </p>
  207. </dd>
  208. <dt><code>-isystem <var>dir</var></code></dt>
  209. <dd><a name="index-isystem-dir"></a>
  210. <a name="index-preprocessing_002c-include-path-5"></a>
  211. <p>Search <var>dir</var> for header files, after all directories specified by
  212. <samp>-I</samp> but before the standard system directories. Mark it as a
  213. system directory, so that it gets the same special treatment as is
  214. applied to the standard system directories. If <var>dir</var> begins with
  215. <code>=</code>, then the <code>=</code> will be replaced by the sysroot prefix;
  216. see <samp>--sysroot</samp> and <samp>-isysroot</samp>.
  217. </p>
  218. </dd>
  219. <dt><code>-nostdinc</code></dt>
  220. <dd><a name="index-nostdinc"></a>
  221. <p>Do not search the standard system directories for header files. Only
  222. the directories you have specified with <samp>-I</samp> options (and the
  223. directory of the current file, if appropriate) are searched.
  224. </p>
  225. </dd>
  226. <dt><code>-undef</code></dt>
  227. <dd><a name="index-undef"></a>
  228. <p>Do not predefine any system-specific or GCC-specific macros.
  229. The standard predefined macros remain defined.
  230. </p>
  231. </dd>
  232. <dt><code>-A<var>predicate</var>=<var>answer</var></code></dt>
  233. <dd><a name="index-Apredicate_003danswer"></a>
  234. <a name="index-preprocessing_002c-assertion"></a>
  235. <p>Make an assertion with the predicate <var>predicate</var> and answer <var>answer</var>.
  236. This form is preferred to the older form -A predicate(answer), which is still
  237. supported, because it does not use shell special characters.
  238. </p>
  239. </dd>
  240. <dt><code>-A-<var>predicate</var>=<var>answer</var></code></dt>
  241. <dd><a name="index-A_002dpredicate_003danswer"></a>
  242. <a name="index-preprocessing_002c-assertion-1"></a>
  243. <p>Cancel an assertion with the predicate <var>predicate</var> and answer <var>answer</var>.
  244. </p>
  245. </dd>
  246. <dt><code>-C</code></dt>
  247. <dd><a name="index-C"></a>
  248. <a name="index-preprocessing_002c-keep-comments"></a>
  249. <p>Do not discard comments. All comments are passed through to the output
  250. file, except for comments in processed directives, which are deleted
  251. along with the directive.
  252. </p>
  253. <p>You should be prepared for side effects when using <samp>-C</samp>; it causes
  254. the preprocessor to treat comments as tokens in their own right. For example,
  255. comments appearing at the start of what would be a directive line have the
  256. effect of turning that line into an ordinary source line, since the first
  257. token on the line is no longer a <code>'#'</code>.
  258. </p>
  259. <p>Warning: this currently handles C-Style comments only. The preprocessor
  260. does not yet recognize Fortran-style comments.
  261. </p>
  262. </dd>
  263. <dt><code>-CC</code></dt>
  264. <dd><a name="index-CC"></a>
  265. <a name="index-preprocessing_002c-keep-comments-1"></a>
  266. <p>Do not discard comments, including during macro expansion. This is like
  267. <samp>-C</samp>, except that comments contained within macros are also passed
  268. through to the output file where the macro is expanded.
  269. </p>
  270. <p>In addition to the side-effects of the <samp>-C</samp> option, the <samp>-CC</samp>
  271. option causes all C++-style comments inside a macro to be converted to C-style
  272. comments. This is to prevent later use of that macro from inadvertently
  273. commenting out the remainder of the source line. The <samp>-CC</samp> option
  274. is generally used to support lint comments.
  275. </p>
  276. <p>Warning: this currently handles C- and C++-Style comments only. The
  277. preprocessor does not yet recognize Fortran-style comments.
  278. </p>
  279. </dd>
  280. <dt><code>-D<var>name</var></code></dt>
  281. <dd><a name="index-Dname"></a>
  282. <a name="index-preprocessing_002c-define-macros"></a>
  283. <p>Predefine name as a macro, with definition <code>1</code>.
  284. </p>
  285. </dd>
  286. <dt><code>-D<var>name</var>=<var>definition</var></code></dt>
  287. <dd><a name="index-Dname_003ddefinition"></a>
  288. <a name="index-preprocessing_002c-define-macros-1"></a>
  289. <p>The contents of <var>definition</var> are tokenized and processed as if they
  290. appeared during translation phase three in a <code>'#define'</code> directive.
  291. In particular, the definition will be truncated by embedded newline
  292. characters.
  293. </p>
  294. <p>If you are invoking the preprocessor from a shell or shell-like program
  295. you may need to use the shell&rsquo;s quoting syntax to protect characters such
  296. as spaces that have a meaning in the shell syntax.
  297. </p>
  298. <p>If you wish to define a function-like macro on the command line, write
  299. its argument list with surrounding parentheses before the equals sign
  300. (if any). Parentheses are meaningful to most shells, so you will need
  301. to quote the option. With sh and csh, <code>-D'name(args...)=definition'</code>
  302. works.
  303. </p>
  304. <p><samp>-D</samp> and <samp>-U</samp> options are processed in the order they are
  305. given on the command line. All -imacros file and -include file options
  306. are processed after all -D and -U options.
  307. </p>
  308. </dd>
  309. <dt><code>-H</code></dt>
  310. <dd><a name="index-H"></a>
  311. <p>Print the name of each header file used, in addition to other normal
  312. activities. Each name is indented to show how deep in the <code>'#include'</code>
  313. stack it is.
  314. </p>
  315. </dd>
  316. <dt><code>-P</code></dt>
  317. <dd><a name="index-P"></a>
  318. <a name="index-preprocessing_002c-no-linemarkers"></a>
  319. <p>Inhibit generation of linemarkers in the output from the preprocessor.
  320. This might be useful when running the preprocessor on something that
  321. is not C code, and will be sent to a program which might be confused
  322. by the linemarkers.
  323. </p>
  324. </dd>
  325. <dt><code>-U<var>name</var></code></dt>
  326. <dd><a name="index-Uname"></a>
  327. <a name="index-preprocessing_002c-undefine-macros"></a>
  328. <p>Cancel any previous definition of <var>name</var>, either built in or provided
  329. with a <samp>-D</samp> option.
  330. </p></dd>
  331. </dl>
  332. <hr>
  333. <div class="header">
  334. <p>
  335. Next: <a href="Error-and-Warning-Options.html#Error-and-Warning-Options" accesskey="n" rel="next">Error and Warning Options</a>, Previous: <a href="Fortran-Dialect-Options.html#Fortran-Dialect-Options" accesskey="p" rel="prev">Fortran Dialect Options</a>, Up: <a href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran" accesskey="u" rel="up">Invoking GNU Fortran</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  336. </div>
  337. </body>
  338. </html>