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.

Preprocessor-Output.html 7.6KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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>Preprocessor Output (The C Preprocessor)</title>
  21. <meta name="description" content="Preprocessor Output (The C Preprocessor)">
  22. <meta name="keywords" content="Preprocessor Output (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="Traditional-Mode.html#Traditional-Mode" rel="next" title="Traditional Mode">
  31. <link href="Other-Directives.html#Other-Directives" rel="prev" title="Other Directives">
  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="Preprocessor-Output"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Traditional-Mode.html#Traditional-Mode" accesskey="n" rel="next">Traditional Mode</a>, Previous: <a href="Other-Directives.html#Other-Directives" accesskey="p" rel="prev">Other Directives</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="Preprocessor-Output-1"></a>
  68. <h2 class="chapter">9 Preprocessor Output</h2>
  69. <p>When the C preprocessor is used with the C, C++, or Objective-C
  70. compilers, it is integrated into the compiler and communicates a stream
  71. of binary tokens directly to the compiler&rsquo;s parser. However, it can
  72. also be used in the more conventional standalone mode, where it produces
  73. textual output.
  74. </p>
  75. <a name="index-output-format"></a>
  76. <p>The output from the C preprocessor looks much like the input, except
  77. that all preprocessing directive lines have been replaced with blank
  78. lines and all comments with spaces. Long runs of blank lines are
  79. discarded.
  80. </p>
  81. <p>The ISO standard specifies that it is implementation defined whether a
  82. preprocessor preserves whitespace between tokens, or replaces it with
  83. e.g. a single space. In GNU CPP, whitespace between tokens is collapsed
  84. to become a single space, with the exception that the first token on a
  85. non-directive line is preceded with sufficient spaces that it appears in
  86. the same column in the preprocessed output that it appeared in the
  87. original source file. This is so the output is easy to read.
  88. CPP does not insert any
  89. whitespace where there was none in the original source, except where
  90. necessary to prevent an accidental token paste.
  91. </p>
  92. <a name="index-linemarkers"></a>
  93. <p>Source file name and line number information is conveyed by lines
  94. of the form
  95. </p>
  96. <div class="smallexample">
  97. <pre class="smallexample"># <var>linenum</var> <var>filename</var> <var>flags</var>
  98. </pre></div>
  99. <p>These are called <em>linemarkers</em>. They are inserted as needed into
  100. the output (but never within a string or character constant). They mean
  101. that the following line originated in file <var>filename</var> at line
  102. <var>linenum</var>. <var>filename</var> will never contain any non-printing
  103. characters; they are replaced with octal escape sequences.
  104. </p>
  105. <p>After the file name comes zero or more flags, which are &lsquo;<samp>1</samp>&rsquo;,
  106. &lsquo;<samp>2</samp>&rsquo;, &lsquo;<samp>3</samp>&rsquo;, or &lsquo;<samp>4</samp>&rsquo;. If there are multiple flags, spaces
  107. separate them. Here is what the flags mean:
  108. </p>
  109. <dl compact="compact">
  110. <dt>&lsquo;<samp>1</samp>&rsquo;</dt>
  111. <dd><p>This indicates the start of a new file.
  112. </p></dd>
  113. <dt>&lsquo;<samp>2</samp>&rsquo;</dt>
  114. <dd><p>This indicates returning to a file (after having included another file).
  115. </p></dd>
  116. <dt>&lsquo;<samp>3</samp>&rsquo;</dt>
  117. <dd><p>This indicates that the following text comes from a system header file,
  118. so certain warnings should be suppressed.
  119. </p></dd>
  120. <dt>&lsquo;<samp>4</samp>&rsquo;</dt>
  121. <dd><p>This indicates that the following text should be treated as being
  122. wrapped in an implicit <code>extern &quot;C&quot;</code> block.
  123. </p></dd>
  124. </dl>
  125. <p>As an extension, the preprocessor accepts linemarkers in non-assembler
  126. input files. They are treated like the corresponding &lsquo;<samp>#line</samp>&rsquo;
  127. directive, (see <a href="Line-Control.html#Line-Control">Line Control</a>), except that trailing flags are
  128. permitted, and are interpreted with the meanings described above. If
  129. multiple flags are given, they must be in ascending order.
  130. </p>
  131. <p>Some directives may be duplicated in the output of the preprocessor.
  132. These are &lsquo;<samp>#ident</samp>&rsquo; (always), &lsquo;<samp>#pragma</samp>&rsquo; (only if the
  133. preprocessor does not handle the pragma itself), and &lsquo;<samp>#define</samp>&rsquo; and
  134. &lsquo;<samp>#undef</samp>&rsquo; (with certain debugging options). If this happens, the
  135. &lsquo;<samp>#</samp>&rsquo; of the directive will always be in the first column, and there
  136. will be no space between the &lsquo;<samp>#</samp>&rsquo; and the directive name. If macro
  137. expansion happens to generate tokens which might be mistaken for a
  138. duplicated directive, a space will be inserted between the &lsquo;<samp>#</samp>&rsquo; and
  139. the directive name.
  140. </p>
  141. <hr>
  142. <div class="header">
  143. <p>
  144. Next: <a href="Traditional-Mode.html#Traditional-Mode" accesskey="n" rel="next">Traditional Mode</a>, Previous: <a href="Other-Directives.html#Other-Directives" accesskey="p" rel="prev">Other Directives</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>
  145. </div>
  146. </body>
  147. </html>