Preprocessor-Output.html 7.7 KB

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