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.
我已经开始研究一个在 pch 文件中有大量导入的项目。
为什么有人会这样做?懒惰?
我想如果我重构它们,我可能会减少编译时间......是这样吗?
不,除非它正在导入经常变化的东西。预编译头文件的要点在于它将大量很少更改的代码组合成中间格式以减少编译时间。如果你取出东西,它必须正常处理每个导入,而不是使用中间格式。
从预编译的头文件中取出东西通常会减慢编译时间。例外情况是,如果您要导入定期更改的内容,因为这会通过强制它每次编译来破坏它的目的。