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