Knowledge

Translation unit (programming)

Source ๐Ÿ“

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

Index

Compilation unit
translation unit

verification
improve this article
adding citations to reliable sources
"Translation unit" programming
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
C
C++
compiler
object file
source file
C preprocessor
header files
#include directives
included
source files
C preprocessor
preprocessed
header files
macro expansion
conditional compilation
object file
linked

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

โ†‘