什么是“翻译单元"?在C ++中? [英] What is a "translation unit" in C++?
问题描述
我当时正在阅读"Effective C ++".由 Scott Meyers 撰写并遇到了翻译单元"一词.
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:
-
这到底是什么?
What exactly it is?
在使用C ++编程时,什么时候应该考虑使用它?
When should I consider using it while programming with C++?
它仅与C ++有关,还是可以与其他编程语言一起使用?
Is it related to C++ only, or it can be used with other programming languages as well?
我可能已经在不知道该术语的情况下使用它了...
I might already use it without knowing the term...
推荐答案
根据标准C ++ (
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.
这篇关于什么是“翻译单元"?在C ++中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!