HiveBrain v1.2.0
Get Started
← Back to all entries
patterncppCritical

What is a "translation unit" in C++?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
whattranslationunit

Problem

I am reading at the time the "Effective C++" written by Scott Meyers
and came across the term "translation unit".

Could somebody please give me an explanation of the following:

-
What exactly is it?

-
When should I consider using it while programming with C++?

-
Is it C++ only, or can it be used with other programming languages?

I might already use it without knowing the term...

Solution

From here: (wayback machine link)


According to standard C++ (wayback machine link) :
A translation unit is the basic unit
of compilation in C++. It consists of
the contents of a single source file,
plus the contents of any header files
directly or indirectly included by it,
minus those lines that were ignored
using conditional preprocessing
statements.


A single translation unit can be
compiled into an object file, library,
or executable program.


The notion of a translation unit is
most often mentioned in the contexts
of the One Definition Rule, and
templates.

Context

Stack Overflow Q#1106149, score: 360

Revisions (0)

No revisions yet.