Using Precompiled Headers with VS2008 takes longer

女生的网名这么多〃 提交于 2020-01-06 04:52:08

问题


I am trying to use PCH in my solution to cut compilation time, but unbelievably, it takes more than twice as long with compared to without. Here's the stats:

Windows 7 x64 with 8GB running on i7

Sample project: 235 cpp files for a total of 4.5 MB source code (using MFC)

With PCH takes 13:55 minutes

Without PCH takes 6:15 minutes

I'm pretty sure I'm using them correctly, the project is set to Use Precompiled Headers at the project level, and the StdAfx.cpp is set to Create Precompiled Headers, through StdAfx.h

All standard #includes are placed in StdAfx.h, and all cpp files start with

#include "StdAfx.h"

I can't make sense of it. Anyone have an ideas what could be happening, or how I would even start to try to work it out?


回答1:


So I worked around this eventually. My solution has a structure as follows:

C:\Data\Bus\VS\Projects\Solution.sln
C:\Data\Bus\VS\Projects\Proj1\
C:\Data\Bus\VS\Projects\Proj2\
C:\Data\Bus\VS\Projects\Proj3\
etc

Because these are used all the time, I have mapped a drive letter:

P = C:\Data\Bus\VS\Projects\

to this area for easier access to the solution using the following:

P:\Solution.sln
P:\Proj1\
P:\Proj2\
P:\Proj3\

I have found that VS2008 does not like opening the solution via the mapped drive letter (P), this is where the slower build with PCH occurs.

But if I open with a full path directly to the C drive, the PCH gives excellent speed advantage as expected.

Anyone have any idea about this? I can only think that the drive aliasing is giving VS the wrong impression that the PCH is always out of date, and so it rebuilds it with every file. Very mysterious.



来源:https://stackoverflow.com/questions/10810395/using-precompiled-headers-with-vs2008-takes-longer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!