C++ - What is a translation unit?

A C++ program consists of a number of translation units.

A translation unit (TU) is the post-processed source code that is used as input to the compiler, the output of which is an object file.
A TU comprises a single source file (C or CPP), with all header files included, and after all preprocessor statements have been evaluated.

All names within a translation unit have internal linkage and can be resolved by the compiler. Names in other translation units have external linkage must be resolved by the linker.

A translation unit is sometimes called a compilation unit.

Ads by Google


Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath