在 VS2008 中使用预编译头文件需要更长的时间 [英] Using Precompiled Headers with VS2008 takes longer

查看:24
本文介绍了在 VS2008 中使用预编译头文件需要更长的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的解决方案中使用 PCH 来缩短编译时间,但令人难以置信的是,与不使用相比,使用所需的时间是 的两倍多.统计如下:

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:

在 i7 上运行 8GB 的​​ Windows 7 x64

Windows 7 x64 with 8GB running on i7

示例项目:235 个 cpp 文件,共 4.5 MB 源代码(使用 MFC)

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

使用 PCH 需要 13:55 分钟

With PCH takes 13:55 minutes

没有 PCH 需要 6:15 分钟

Without PCH takes 6:15 minutes

我很确定我正确使用它们,项目在项目级别设置为使用预编译头,并且 StdAfx.cpp 设置为通过 StdAfx.h 创建预编译头

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

所有标准#includes都放在StdAfx.h中,所有cpp文件都以

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

#include "StdAfx.h"

#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?

推荐答案

所以我最终解决了这个问题.我的解决方案结构如下:

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\

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\

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\

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

我发现 VS2008 不喜欢通过映射的驱动器号 (P) 打开解决方案,这就是使用 PCH 构建速度较慢的地方.

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.

但是如果我直接打开到 C 盘的完整路径,PCH 会像预期的那样提供出色的速度优势.

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

有人对此有任何想法吗?我只能认为驱动器别名给了 VS 错误的印象,即 PCH 总是过时的,因此它会用每个文件重建它.很神秘.

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.

这篇关于在 VS2008 中使用预编译头文件需要更长的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆