Sharing precompiled headers between projects in Visual Studio

后端 未结 6 1417
野性不改
野性不改 2020-12-01 01:25

I have a solution with many Visual C++ projects, all using PCH, but some have particular compiler switches turned on for project-specific needs.

Most of these projec

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 01:58

    This sounds like a case of "diminishing returns" to me. Suppose including the common headers directly wastes 1 second per .cpp file, and each target (DLL/EXE) has 10 .cpp files. By using a .pch per target, you save 10 seconds per target. If your whole project has 10 targets, you save 1.5 minutes on the whole build, which is good.

    But by reducing it to one .pch for the whole project, you'd only save a further 9 seconds. Is it worth it? The extra effort (which may be a lot more fiddly to set up, being a non-standard configuration unsupported by VS wizards) produces only a 10th of the saving.

提交回复
热议问题