Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
据我所知,翻译单元由单个实现文件 .cpp/.c 及其所有包含的标头代码组成。当在另一个 .cpp 文件中包含一个 .cpp 文件,或者在另一个 .cpp 文件中包含一个 .h 文件中包含一个 .cpp 文件时,我们这里有什么翻译单元?
当在另一个 .cpp 文件中包含一个 .cpp 文件,或者在另一个 .cpp 文件中包含一个 .h 文件中包含一个 .cpp 文件时,我们这里有什么翻译单元?
翻译单元是正在编译的单个文件。这是“最外层”的.cpp文件。
.cpp
也就是说,内部是#including一个非常糟糕的主意™️。.cpp.h
#including
.h