Does a module with multiple source files (.cpp) have one or multiple translation units? My understanding is that every single source file (.cpp) will be its own translation unit unless it is included, and #pragma onced (which I guess is a malpractice), but I don't know how that is done in a modular program. If there's any difference, then I am particularly interested in Visual Studio C++ development (post C++2020)
Asked
Active
Viewed 191 times
1
-
3To summarize (and simplify): A translation unit is a single preprocessed source file. It's the unit that the compiler itself is working with. You can then take multiple translation units to create a library, an executable, or a module. – Some programmer dude Dec 13 '21 at 13:34
1 Answers
2
A module consists of one or more translation units. A translation unit that starts with a module declaration is termed a module unit, and if there are multiple module units in a program that have the same module name (ignoring any module partition) then they belong to the same module.

Brian Bi
- 111,498
- 10
- 176
- 312