开发者

Is there a way of structuring precompiled headers in VS that doesn't make my code awkward to build in GCC?

In the past I've used precompiled headers in VC to speed up compile times but usually only in smaller projects that are basically just a small directory of source code. Since VC++ requires that all files include the same header exactly regardless of path (say "foo.h" and not "../foo.h") things get hairy when you have different nested directories of source. If all my files just

#include "foo.h" 

it works but only when I have precompiled headers on. To make this work in all cases I need to make dummy foo.h files that go

#include "../foo.h"

This starts to get ridiculous pretty fast especially when you have multiple levels.

Even though I typically prefer Microsoft tools I have to say that GCC's system where you开发者_StackOverflow社区 manually compile your headers into .gch files seems far superior to me. It is much less intrusive and doesn't require you to include all your headers in every compilation unit which is ugly and slow if you are building on a compiler without precompiled headers.

Am I missing something about the VC version? None of the large projects I've worked on professionally have used precompiled headers and I want to make sure I give them a fair shake before I give up and just accept the longer compile times.

Is there a cleaner way of doing this?

Thanks!


Is it possible to update project include path, so there is no need to create separate header. We used header file Common/Common.h to create precompiled header in all projects.

If the problem is compilation time, different approaches may address it: we removed precompiled headers from the project, as distributed compilation was significantly faster wihout them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜