32:
265:
level โ it does not do parsing, and thus is unable to do any processing specific to C syntax. The input to the compiler is the translation unit, and thus it does not see any preprocessor directives, which have all been processed before compiling starts. While a given translation unit is fundamentally
294:
in C. Names (functions and variables) declared outside of a function block may be visible either only within a given translation unit, in which case they are said to have internal linkage โ they are not visible to the linker โ or may be visible to other object files, in which case they are said to
302:
C does not have a notion of modules. However, separate object files (and hence also the translation units used to produce object files) function similarly to separate modules, and if a source file does not include other source files, internal linkage (translation unit scope) may be thought of as
351:
is the most common even for C++), and generally do not contain function or variable definitions to avoid name conflicts when headers are included in multiple source files, as is often the case. Header files can be, and often are, included in other header files. It is standard practice for all
266:
based on a file, the actual source code fed into the compiler may appear substantially different than the source file that the programmer views, particularly due to the recursive inclusion of headers.
49:
96:
68:
406:
115:
75:
82:
411:
53:
64:
42:
129:
369:
229:
89:
19:
This article is about the C and C++ programming term. For the meaning of the term in linguistics, see
258:
275:
291:
245:
161:
388:
296:
287:
262:
20:
201:. A translation unit is the output of the C preprocessor โ a source file after it has been
221:
198:
153:
400:
208:
Preprocessing notably consists of expanding a source file to recursively replace all
236:
directives, among others; this translates the preprocessing translation unit into a
283:
202:
168:
241:
213:
189:
157:
149:
145:
31:
279:
249:
335:
is used most conventionally). Files intended to be included typically have a
140:(or more casually a compilation unit) is the ultimate input to a C or C++
141:
389:
ISO/IEC 9899:TC3 - Committee Draft of the C99 Standard - Section 5.1.1.1
257:
Note that the preprocessor is in principle language agnostic, and is a
212:
directives with the literal file declared in the directive (usually
328:
133:
16:
Input to a C or C++ compiler from which an object file is generated
197:), which, in addition to source code, includes directives for the
216:, but possibly other source files); the result of this step is a
311:
The bulk of a project's code is typically held in files with a
25:
148:
is generated. A translation unit roughly consists of a
240:. From a translation unit, the compiler generates an
56:. Unsourced material may be challenged and removed.
175:may be included, and macros have been expanded.
248:(possibly with other object files) to form an
8:
356:files in a project to include at least one
303:"file scope, including all header files".
286:; in C terminology this is referred to as
116:Learn how and when to remove this message
381:
244:, which can be further processed and
7:
136:programming language terminology, a
54:adding citations to reliable sources
290:, which is one of the two forms of
152:after it has been processed by the
65:"Translation unit" programming
14:
299:, and are visible to the linker.
30:
282:, and functioning similarly to
41:needs additional citations for
218:preprocessing translation unit
1:
347:are also used for C++, but
274:Translation units define a
428:
171:, sections of code within
18:
407:C (programming language)
220:. Further steps include
183:A C program consists of
370:Single compilation unit
230:conditional compilation
412:Compiler construction
259:lexical preprocessor
50:improve this article
195:preprocessing files
251:executable program
307:Code organization
261:, working at the
126:
125:
118:
100:
419:
391:
386:
359:
355:
350:
346:
342:
338:
334:
326:
322:
318:
314:
297:external linkage
288:internal linkage
263:lexical analysis
238:translation unit
235:
228:directives, and
227:
211:
174:
164:
138:translation unit
121:
114:
110:
107:
101:
99:
58:
34:
26:
21:translation unit
427:
426:
422:
421:
420:
418:
417:
416:
397:
396:
395:
394:
387:
383:
378:
366:
357:
353:
348:
344:
340:
336:
332:
324:
320:
316:
312:
309:
272:
233:
225:
222:macro expansion
209:
181:
172:
162:
156:, meaning that
122:
111:
105:
102:
59:
57:
47:
35:
24:
17:
12:
11:
5:
425:
423:
415:
414:
409:
399:
398:
393:
392:
380:
379:
377:
374:
373:
372:
365:
362:
308:
305:
271:
268:
199:C preprocessor
180:
177:
167:are literally
154:C preprocessor
144:from which an
124:
123:
38:
36:
29:
15:
13:
10:
9:
6:
4:
3:
2:
424:
413:
410:
408:
405:
404:
402:
390:
385:
382:
375:
371:
368:
367:
363:
361:
330:
306:
304:
300:
298:
293:
289:
285:
281:
277:
269:
267:
264:
260:
255:
253:
252:
247:
243:
239:
231:
223:
219:
215:
206:
204:
200:
196:
192:
191:
186:
178:
176:
170:
166:
159:
155:
151:
147:
143:
139:
135:
131:
120:
117:
109:
98:
95:
91:
88:
84:
81:
77:
74:
70:
67: โ
66:
62:
61:Find sources:
55:
51:
45:
44:
39:This article
37:
33:
28:
27:
22:
384:
310:
301:
284:module scope
273:
256:
250:
237:
217:
214:header files
207:
203:preprocessed
194:
190:source files
188:
184:
182:
158:header files
137:
127:
112:
106:October 2015
103:
93:
86:
79:
72:
60:
48:Please help
43:verification
40:
331:, of which
315:suffix (or
242:object file
150:source file
146:object file
401:Categories
376:References
280:file scope
278:, roughly
165:directives
160:listed in
76:newspapers
339:suffix (
364:See also
210:#include
169:included
163:#include
142:compiler
292:linkage
226:#define
187:called
179:Context
173:#ifndef
90:scholar
360:file.
246:linked
234:#ifdef
92:
85:
78:
71:
63:
295:have
276:scope
270:Scope
185:units
97:JSTOR
83:books
341:.hpp
333:.cpp
327:for
321:.cxx
317:.cpp
193:(or
132:and
69:news
345:.hh
343:or
329:C++
325:.cc
323:or
254:.
232:of
224:of
134:C++
128:In
52:by
403::
358:.h
354:.c
349:.h
337:.h
319:,
313:.c
205:.
130:C
119:)
113:(
108:)
104:(
94:ยท
87:ยท
80:ยท
73:ยท
46:.
23:.
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.