C++ 模块:用于不必要的重新编译的模块实现单元?
C++ modules: module implementation units for unnecessary recompilation?
最近观看的 CppCon 2017 视频:Boris Kolpackov “Building C++ Modules”
https://www.youtube.com/watch?v=E8EbDcLQAoc
大约在 31:35 时,他开始解释我们仍应使用 header/source 拆分并给出了 3 个原因。第一个原因:
如果您在触摸此模块时将两个 declarations/definitions 放在同一位置,则所有其他依赖于 模块接口 (BMI) 的模块都将被重新编译。
而且我一点也不喜欢。听起来我们还处于 90 年代,编译器还不够聪明,看不出 BMI 相关更改和实现相关更改之间的差异。正如我所见,编译器能够快速扫描每个模块并从中仅生成 BMI。如果 BMI 没有改变 - 不要重新编译依赖它的其他模块。
还是我遗漏了什么?
那个演讲的作者后来说重新编译问题是一个实现问题。引用 Boris Kolpackov 的文章 Common C++ Modules TS Misconceptions:
It turns out a lot of people would like to get rid of the header/source split (or, in modules terms, interface/implementation split) and keep everything in a single file. You can do that in Modules TS: with modules (unlike headers) you can define non-inline functions and variables in module interface units. So if you want to keep everything in a single file, you can.
和
Now, keeping everything in a single file may have negative build performance implications but it appears a smart enough build system in cooperation with the compiler should be able to overcome this. See this discussion for details.
从链接线程中引用 Gor Nishanov(Coroutines TS 的项目编辑器):
That is up to you how to structure your code. Module TS does not impose on you how you decompose your module into individual files. If you want, you can implement your entire module in the interface file (thus you will have C# like experience), or you can partition your module into an interface and one or more implementation files.
Modules TS, Gabriel Dos Reis, commented on the MSVC implementation 的项目编辑:
Ideally, only semantics-relevant changes should trigger recompilation keyed on the IFC.
(作为旁注,模块 TS has now been approved 并发送给 ISO 进行发布。)
最近观看的 CppCon 2017 视频:Boris Kolpackov “Building C++ Modules” https://www.youtube.com/watch?v=E8EbDcLQAoc
大约在 31:35 时,他开始解释我们仍应使用 header/source 拆分并给出了 3 个原因。第一个原因:
如果您在触摸此模块时将两个 declarations/definitions 放在同一位置,则所有其他依赖于 模块接口 (BMI) 的模块都将被重新编译。
而且我一点也不喜欢。听起来我们还处于 90 年代,编译器还不够聪明,看不出 BMI 相关更改和实现相关更改之间的差异。正如我所见,编译器能够快速扫描每个模块并从中仅生成 BMI。如果 BMI 没有改变 - 不要重新编译依赖它的其他模块。
还是我遗漏了什么?
那个演讲的作者后来说重新编译问题是一个实现问题。引用 Boris Kolpackov 的文章 Common C++ Modules TS Misconceptions:
It turns out a lot of people would like to get rid of the header/source split (or, in modules terms, interface/implementation split) and keep everything in a single file. You can do that in Modules TS: with modules (unlike headers) you can define non-inline functions and variables in module interface units. So if you want to keep everything in a single file, you can.
和
Now, keeping everything in a single file may have negative build performance implications but it appears a smart enough build system in cooperation with the compiler should be able to overcome this. See this discussion for details.
从链接线程中引用 Gor Nishanov(Coroutines TS 的项目编辑器):
That is up to you how to structure your code. Module TS does not impose on you how you decompose your module into individual files. If you want, you can implement your entire module in the interface file (thus you will have C# like experience), or you can partition your module into an interface and one or more implementation files.
Modules TS, Gabriel Dos Reis, commented on the MSVC implementation 的项目编辑:
Ideally, only semantics-relevant changes should trigger recompilation keyed on the IFC.
(作为旁注,模块 TS has now been approved 并发送给 ISO 进行发布。)