Translation unit (programming)
Encyclopedia
In C programming language
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 terminology, a translation unit is the ultimate input to a C compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 from which an object file
Object file
An object file is a file containing relocatable format machine code that is usually not directly executable. Object files are produced by an assembler, compiler, or other language translator, and used as input to the linker....

 gets generated.

Context

A C program consists of units called source files
Source code
In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...

(or preprocessing files). When the C preprocessor
C preprocessor
The C preprocessor is the preprocessor for the C and C++ computer programming languages. The preprocessor handles directives for source file inclusion , macro definitions , and conditional inclusion ....

 expands a source file with all header file
Header file
Some programming languages use header files. These files allow programmers to separate certain elements of a program's source code into reusable files. Header files commonly contain forward declarations of classes, subroutines, variables, and other identifiers...

s declared by #include directives, the result is a preprocessing translation unit. Further preprocessing translates the preprocessing translation unit into a translation unit. From a translation unit, the compiler generates an object file
Object file
An object file is a file containing relocatable format machine code that is usually not directly executable. Object files are produced by an assembler, compiler, or other language translator, and used as input to the linker....

, which can be further processed and linked (possibly with other object files) to form an executable program
Executable
In computing, an executable file causes a computer "to perform indicated tasks according to encoded instructions," as opposed to a data file that must be parsed by a program to be meaningful. These instructions are traditionally machine code instructions for a physical CPU...

.

The bulk of a project's code is typically held in files with a .c suffix (or .c++ or .cpp for C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

). Files intended to be included typically have a .h suffix, and generally do not contain function or variable declarations to avoid name conflicts when headers are included in multiple source files, as is often the case. Header files can and often are included in other header files. It is standard practice for all .c files in a project to include at least one .h file.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK