index.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  4. <head>
  5. <title>The GNU C Preprocessor Internals: Top</title>
  6. <meta name="description" content="The GNU C Preprocessor Internals: Top">
  7. <meta name="keywords" content="The GNU C Preprocessor Internals: Top">
  8. <meta name="resource-type" content="document">
  9. <meta name="distribution" content="global">
  10. <meta name="Generator" content="makeinfo">
  11. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  12. <link href="#Top" rel="start" title="Top">
  13. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  14. <link href="#SEC_Contents" rel="contents" title="Table of Contents">
  15. <link href="../dir/index.html" rel="up" title="(dir)">
  16. <link href="Conventions.html#Conventions" rel="next" title="Conventions">
  17. <style type="text/css">
  18. <!--
  19. a.summary-letter {text-decoration: none}
  20. blockquote.smallquotation {font-size: smaller}
  21. div.display {margin-left: 3.2em}
  22. div.example {margin-left: 3.2em}
  23. div.indentedblock {margin-left: 3.2em}
  24. div.lisp {margin-left: 3.2em}
  25. div.smalldisplay {margin-left: 3.2em}
  26. div.smallexample {margin-left: 3.2em}
  27. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  28. div.smalllisp {margin-left: 3.2em}
  29. kbd {font-style:oblique}
  30. pre.display {font-family: inherit}
  31. pre.format {font-family: inherit}
  32. pre.menu-comment {font-family: serif}
  33. pre.menu-preformatted {font-family: serif}
  34. pre.smalldisplay {font-family: inherit; font-size: smaller}
  35. pre.smallexample {font-size: smaller}
  36. pre.smallformat {font-family: inherit; font-size: smaller}
  37. pre.smalllisp {font-size: smaller}
  38. span.nocodebreak {white-space:nowrap}
  39. span.nolinebreak {white-space:nowrap}
  40. span.roman {font-family:serif; font-weight:normal}
  41. span.sansserif {font-family:sans-serif; font-weight:normal}
  42. ul.no-bullet {list-style: none}
  43. -->
  44. </style>
  45. </head>
  46. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  47. <h1 class="settitle" align="center">The GNU C Preprocessor Internals</h1>
  48. <a name="SEC_Contents"></a>
  49. <h2 class="contents-heading">Table of Contents</h2>
  50. <div class="contents">
  51. <ul class="no-bullet">
  52. <li><a name="toc-Cpplib_002d_002d_002dthe-GNU-C-Preprocessor" href="#Cpplib_002d_002d_002dthe-GNU-C-Preprocessor">1 Cpplib&mdash;the GNU C Preprocessor</a></li>
  53. <li><a name="toc-Conventions-1" href="Conventions.html#Conventions">Conventions</a></li>
  54. <li><a name="toc-The-Lexer" href="Lexer.html#Lexer">The Lexer</a>
  55. <ul class="no-bullet">
  56. <li><a name="toc-Overview" href="Lexer.html#Overview">Overview</a></li>
  57. <li><a name="toc-Lexing-a-token" href="Lexer.html#Lexing-a-token">Lexing a token</a></li>
  58. <li><a name="toc-Lexing-a-line-1" href="Lexer.html#Lexing-a-line-1">Lexing a line</a></li>
  59. </ul></li>
  60. <li><a name="toc-Hash-Nodes-1" href="Hash-Nodes.html#Hash-Nodes">Hash Nodes</a></li>
  61. <li><a name="toc-Macro-Expansion-Algorithm" href="Macro-Expansion.html#Macro-Expansion">Macro Expansion Algorithm</a>
  62. <ul class="no-bullet">
  63. <li><a name="toc-Internal-representation-of-macros" href="Macro-Expansion.html#Internal-representation-of-macros">Internal representation of macros</a></li>
  64. <li><a name="toc-Macro-expansion-overview" href="Macro-Expansion.html#Macro-expansion-overview">Macro expansion overview</a></li>
  65. <li><a name="toc-Scanning-the-replacement-list-for-macros-to-expand" href="Macro-Expansion.html#Scanning-the-replacement-list-for-macros-to-expand">Scanning the replacement list for macros to expand</a></li>
  66. <li><a name="toc-Looking-for-a-function_002dlike-macro_0027s-opening-parenthesis" href="Macro-Expansion.html#Looking-for-a-function_002dlike-macro_0027s-opening-parenthesis">Looking for a function-like macro&rsquo;s opening parenthesis</a></li>
  67. <li><a name="toc-Marking-tokens-ineligible-for-future-expansion" href="Macro-Expansion.html#Marking-tokens-ineligible-for-future-expansion">Marking tokens ineligible for future expansion</a></li>
  68. </ul></li>
  69. <li><a name="toc-Token-Spacing-1" href="Token-Spacing.html#Token-Spacing">Token Spacing</a></li>
  70. <li><a name="toc-Line-numbering" href="Line-Numbering.html#Line-Numbering">Line numbering</a>
  71. <ul class="no-bullet">
  72. <li><a name="toc-Just-which-line-number-anyway_003f" href="Line-Numbering.html#Just-which-line-number-anyway_003f">Just which line number anyway?</a></li>
  73. <li><a name="toc-Representation-of-line-numbers" href="Line-Numbering.html#Representation-of-line-numbers">Representation of line numbers</a></li>
  74. </ul></li>
  75. <li><a name="toc-The-Multiple_002dInclude-Optimization" href="Guard-Macros.html#Guard-Macros">The Multiple-Include Optimization</a></li>
  76. <li><a name="toc-File-Handling" href="Files.html#Files">File Handling</a></li>
  77. <li><a name="toc-Concept-Index-1" href="Concept-Index.html#Concept-Index">Concept Index</a></li>
  78. </ul>
  79. </div>
  80. <a name="Top"></a>
  81. <div class="header">
  82. <p>
  83. Next: <a href="Conventions.html#Conventions" accesskey="n" rel="next">Conventions</a>, Up: <a href="../dir/index.html" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  84. </div>
  85. <hr>
  86. <a name="SEC_Top"></a>
  87. <a name="Cpplib_002d_002d_002dthe-GNU-C-Preprocessor"></a>
  88. <h2 class="chapter">1 Cpplib&mdash;the GNU C Preprocessor</h2>
  89. <p>The GNU C preprocessor is
  90. implemented as a library, <em>cpplib</em>, so it can be easily shared between
  91. a stand-alone preprocessor, and a preprocessor integrated with the C,
  92. C++ and Objective-C front ends. It is also available for use by other
  93. programs, though this is not recommended as its exposed interface has
  94. not yet reached a point of reasonable stability.
  95. </p>
  96. <p>The library has been written to be re-entrant, so that it can be used
  97. to preprocess many files simultaneously if necessary. It has also been
  98. written with the preprocessing token as the fundamental unit; the
  99. preprocessor in previous versions of GCC would operate on text strings
  100. as the fundamental unit.
  101. </p>
  102. <p>This brief manual documents the internals of cpplib, and explains some
  103. of the tricky issues. It is intended that, along with the comments in
  104. the source code, a reasonably competent C programmer should be able to
  105. figure out what the code is doing, and why things have been implemented
  106. the way they have.
  107. </p>
  108. <table class="menu" border="0" cellspacing="0">
  109. <tr><td align="left" valign="top">&bull; <a href="Conventions.html#Conventions" accesskey="1">Conventions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Conventions used in the code.
  110. </td></tr>
  111. <tr><td align="left" valign="top">&bull; <a href="Lexer.html#Lexer" accesskey="2">Lexer</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The combined C, C++ and Objective-C Lexer.
  112. </td></tr>
  113. <tr><td align="left" valign="top">&bull; <a href="Hash-Nodes.html#Hash-Nodes" accesskey="3">Hash Nodes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">All identifiers are entered into a hash table.
  114. </td></tr>
  115. <tr><td align="left" valign="top">&bull; <a href="Macro-Expansion.html#Macro-Expansion" accesskey="4">Macro Expansion</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Macro expansion algorithm.
  116. </td></tr>
  117. <tr><td align="left" valign="top">&bull; <a href="Token-Spacing.html#Token-Spacing" accesskey="5">Token Spacing</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Spacing and paste avoidance issues.
  118. </td></tr>
  119. <tr><td align="left" valign="top">&bull; <a href="Line-Numbering.html#Line-Numbering" accesskey="6">Line Numbering</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Tracking location within files.
  120. </td></tr>
  121. <tr><td align="left" valign="top">&bull; <a href="Guard-Macros.html#Guard-Macros" accesskey="7">Guard Macros</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Optimizing header files with guard macros.
  122. </td></tr>
  123. <tr><td align="left" valign="top">&bull; <a href="Files.html#Files" accesskey="8">Files</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">File handling.
  124. </td></tr>
  125. <tr><td align="left" valign="top">&bull; <a href="Concept-Index.html#Concept-Index" accesskey="9">Concept Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Index.
  126. </td></tr>
  127. </table>
  128. <hr>
  129. <div class="header">
  130. <p>
  131. Next: <a href="Conventions.html#Conventions" accesskey="n" rel="next">Conventions</a>, Up: <a href="../dir/index.html" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  132. </div>
  133. </body>
  134. </html>