Allow precompiled headers to be shared between projects
In Visual Studio 2008 and earlier, I believe you could (by an unsupported method) allow one project to generate a precompiled header which other projects could then use. But I understand this is not possible, or only works in limited ways in VS 2010 and later.
Please add official support for allowing a precompiled header to be shared between projects.
As a nice to have it would also be ideal if more than one precompiled header could be used by a project so that both a shared and project specific precompiled header could be used.
Look for this soon (but not quite yet)!
Viktor Kirilov commented
any news since march 2016? Could this go into VS 2017?
yes, I like to know how to use it too.
Boris Nikitin commented
How to use it? Where to find it?
Is this going to be in 2015 update3 or what? Where/when/how can I use it? :)
Neil Justice commented
This is quite simply a historic day for C++. Thank you Visual Studio C++ team! I can't wait to see in Visual Studio 2016 the build time reduction when going from compiling ten identical precompiled headers to compiling one precompiled header then sharing it with nine other projects. The parallelism!
so? "completed" or "started"
This will be a big decrease in the compile time.
Is a must have in next release.
I want this feature.
If my previous request is inappropriate,
Please at least add one build config:
Category: Configuration Properties => C/C++ => Precompiled Headeres
Option Name: "Delete PCH on rebuild"
Option Value: "Yes"(default)/"No"
So that users can customize the PCH feature, i.e. shared PCH.
ps. I tried removing *.pch in Configuration Properties => General => Extensions to Delete on Clean, and it doesn't work.
A shared precompiled header is very useful for project independent lib headers, i.e. all C++ STL headers(containers, streams, algorithms), also useful to custom foundation lib headers.
I am able to use shared precompiled header among projects without any copy/build event on Visual Studio 2012. But one problem remains: on rebuild, a project will delete the PCH file even if no files in that project is about to create a PCH file. I have to perform a CLEAN & BUILD to make it work.
At least please change the build config so that DO NOT delete PCH file if no files in the project creates PCH, if it is possible.
@Philippe what are you talking about? You think regenerating the same PCH for 600+ projects is a good idea? You're talking GB's of disk space and maybe 30 mins to generate them all! Vs a few MB and a less than 1 min to generate + share for all projects.
Please vote for the "support c++11 modules" idea, this should reduce the algorithmic complexity of the build
Marián Špánik commented
... or make the C++ compiler faster so the precompiled headers would be not needed. I know it is not as simple as it looks, I have a notion how the compiler's source code looks after all the years just by looking at that full-of-macros Windows.h. The PCHs reduce build times to a tiny fraction so it would need to be blazingly fast to reach that build time without them. Maybe the non-standard modules would do it as the parser would not need to peek that header files over and over for many source files (which takes majority of the build time).
Robert McMillan commented
This would be hugely beneficial for decreasing build times. Sure you can have 10 projects and include the same headers in the precompiled header, but this needs to be compiled 10 times. We routinely have PCH files that take 15 seconds to build, so if you eliminate 9 of these compiles the time really adds up. We have several GBs of PCH files and cutting this down by 90% would probably make the entire build far more disk and memory efficient, which would be an additional win for build speeds.
There is no need for that. Simply include a common file into every precompiled header file. You can then easily hva general things that is used by every project and specific things.
Phil Nash commented
Either this or add full support for modules