What is a “translation unit” in C++

前端 未结 11 708
既然无缘
既然无缘 2020-11-21 07:56

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

Could somebody please give me an explanation of:

11条回答
  •  一生所求
    2020-11-21 08:34

    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.

提交回复
热议问题