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)!
André Poffo commented
It's already possible do that: https://blogs.msdn.microsoft.com/vcblog/2018/07/05/shared-pch-usage-sample-in-visual-studio/
Viktor Kirilov commented
500 upvotes and counting... modules aren't the ultimate savior - this is still a very important feature...
Ah, this issue seems to be resolved/completed. Can somebody add a pointer to a manual/howto?
Trying to get some response on this issue: https://connect.microsoft.com/VisualStudio/feedback/details/3136108
Is this done or not?
Kevin Hall commented
Just keep working on modules. That will have much more benefit than precompiled headers.
S. Colcord commented
We're more than a year after 'soon'...can we have an update on this? I think this item has become more important, because the ISO C++ Modules work won't arrive until C++20, at the earliest.
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).