C ++ defines the concept of "translation unit". The translation block is the anchor point where the translation begins, and the program, as a rule, includes several such translation units. What units are passed to the compiler, since the "translation unit" actually depends on the settings in your IDE, on make files and other configurations. But informally, most configurations accept your .cpp
and .c
files as translation units.
To make this easier, we can think of the translation block as someone from whom the compiler makes binary code, and the linker combines several binary files, and then into a program.
Thus, the header files are usually not configured as translation units, and they usually do not produce the binary on their own, even if they contain source code. Rather, they are considered to be imported from translation units and will be compiled with them.
If such header files contain a lot of source code that will be included in several translation units, it makes sense to (pre) compile them once and save as much information as possible in the intermediate result, so that collecting the actual translation unit is faster. This saves time, but the "intermediate binary" is something internal and not displayed.
However, from the content and type of source code in it, the header file is no different from other source code files. You can pass the “header file” to the compiler as a translation unit, and the compiler will actually make “normal” binary code out of it. It is true that they are usually not declared root for compilation.
Hope this helps.
source share