Separate compilation units vs Single Compilation unit for faster compilation, linking, and optimised code?

后端 未结 2 770
情歌与酒
情歌与酒 2021-02-08 03:34

There are several questions which talk about why we should have separate compilation units so improve compile times (for example, not including any code in the hpp file,but only

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-08 04:18

    If the question is about comparing one cpp including all cpps and one header file including all header files versus one cpp and multiple header files, then I don't think there will be a significant difference (or any at all).

    Including all cpps in one file that is (and probably only that) what makes the difference. But this is a highly theoretical discussion with no real value. No one would ever do this in a project for the reasons all here have mentioned.

    If you want to know what is going on under the hood, read this:

    https://randomascii.wordpress.com/2014/03/22/make-vc-compiles-fast-through-parallel-compilation/

提交回复
热议问题