In C and C++ programming language terminology, a translation unit (or more casually a compilation unit) is the ultimate input to a C or C++ compiler from which an is generated. A translation unit roughly consists of a after it has been processed by the C preprocessor, meaning that s listed in #include directives are literally included, sections of code within #ifndef may be included, and macros have been expanded.
A C program consists of units called source files (or preprocessing files), which, in addition to source code, includes directives for the C preprocessor. A translation unit is the output of the C preprocessor – a source file after it has been preprocessed.
Preprocessing notably consists of expanding a source file to recursively replace all #include directives with the literal file declared in the directive (usually s, but possibly other source files); the result of this step is a preprocessing translation unit. Further steps include macro expansion of #define directives, and conditional compilation of #ifdef directives, among others; this translates the preprocessing translation unit into a translation unit. From a translation unit, the compiler generates an , which can be further processed and linked (possibly with other object files) to form an executable program.
Note that the preprocessor is in principle language agnostic, and is a lexical preprocessor, working at the lexical analysis 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 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.
Translation units define a scope, roughly , and functioning similarly to module scope; in C terminology this is referred to as internal linkage, which is one of the two forms of linkage in C.
This page is automatically generated and may contain information that is not correct, complete, up-to-date, or relevant to your search query. The same applies to every other page on this website. Please make sure to verify the information with EPFL's official sources.
Many programming languages and other computer files have a directive, often called include, import, or copy, that causes the contents of the specified file to be inserted into the original file. These included files are called s or copybooks. They are often used to define the physical layout of program data, pieces of procedural code, and/or forward declarations while promoting encapsulation and the reuse of code or data. In computer programming, a header file is a file that allows programmers to separate certain elements of a program's source code into reusable files.
Ce cours approfondit les connaissances en programmation présentées dans le cours ICC du 1er semestre. L'accent est
mis sur l'approche «orientée objet» (en C++), la conception et la spécification de pr
L'objectif de ce cours est d'introduire les étudiants à la pensée algorithmique, de les familiariser avec les fondamentaux de l'Informatique et de développer une première compétence en programmation (
Practical realizations of quantum computers are poised to deliver outstanding computational capabilities far beyond the reach of any classical supercomputer.
While classical systems are reliably implemented using CMOS technology, the fabrication of quantu ...
EPFL2020
, ,
The Scala compiler uses ASTs (abstract syntax trees) as an intermediate representation before generating bytecode. With the development of Scala macros which expand trees at compile time, being able to access, modify and recompose ASTs within the compilati ...
Macros made their first appearance as a fork of the Scala compiler and then as an experimental feature in the version 2.10.0 of Scala. Since macros are normal Scala functions that are executed by the compiler during the compilation of their clients, they c ...