Preprocessor-Output.html 7.0 KB

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