【问题标题】:Visual Studio 2017 PCH doesn't improve build timeVisual Studio 2017 PCH 不会缩短构建时间
【发布时间】:2017-07-19 14:42:14
【问题描述】:

我为一个项目启用了 PCH。将所有常用的标头(来自 C++ std lib 和 boost)添加到 stdafx.h,添加 stdafx.cpp 并在其中包含 stdafx.h。我在stdafx.cpp的属性中选择了Create,在项目设置中选择了Use。我还在/FI 选项中添加了stdafx.h - 以避免在每个单元中包含stdafx.h

当我重建整个项目时,它首先符合stdafx.cpp 和其他*.cpp 文件 - 没关系,它似乎正在工作。但是如果我更改一个文件然后构建项目,重新编译该单个文件需要花费大量时间,与重新构建整个项目相比,因此 PCH 似乎不起作用,或者它重新构建了 PCH 文件,还是什么?

我做错了什么?

【问题讨论】:

    标签: visual-studio compilation visual-studio-2017 building pch


    【解决方案1】:

    问题出在 /FI 选项中,当我在每个 cpp 文件中明确包含 stdafx.h 时,问题就消失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-15
      • 1970-01-01
      • 2018-04-25
      • 2019-06-18
      • 2018-05-05
      • 1970-01-01
      • 2018-06-03
      相关资源
      最近更新 更多