什么是“翻译单元"?在 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".
谁能给我解释一下:
究竟是什么?
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++ (wayback 机器链接):翻译单元是基本单元在 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屋!