Automatically recreate a missing or corrupted precompiled header file. - by Frank Heimes

Status : 

  Other<br /><br />
		This item had a custom resolution.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 641724 Comments
Status Closed Workarounds
Type Suggestion Repros 0
Opened 2/7/2011 7:33:41 AM
Access Restriction Public


Sometimes, if you cancel a build or if the compiler or linker crashes,
then the precompiled header file can become corrupted.

Restarting the build then produces the following output:

------ Build started: Project: YYY, Configuration: Debug Win32 ------
d:\YYY\MyFile1.cpp(16): fatal error C1083: Cannot open precompiled header file: 'Debug\YYY.pch': No such file or directory
d:\YYY\MyFile2.cpp(16): fatal error C1083: Cannot open precompiled header file: 'Debug\YYY.pch': No such file or directory
d:\YYY\MyFile3.cpp(16): fatal error C1083: Cannot open precompiled header file: 'Debug\YYY.pch': No such file or directory
... et cetera ... et cetera

Well - I got the message - the PCH file is corrupted and needs to be recreated.
So what?
Why do I have to tell VS to do a clean build of the affected project?
Can't the compiler detect a missing or corrupted generated file itself and retrigger a clean rebuild?
Sign in to post a comment.
Posted by Microsoft on 3/18/2011 at 1:15 PM

I don't think this is quite the same issue as 626218. It looks to me like that issue had to do with the build system knowing to rebuild the PCH if it had been deleted. This issue has to do with the compiler recognizing a corrupt PCH and automatically regenerating it. (As far as I can tell, the fix for the other issue should appear in the next major release of Visual Studio.)

Jamie Eckman
Visual C++ Team
Posted by GregM on 3/7/2011 at 2:16 PM
Looks like this might be the same as which was marked as fixed without any indication of how or when it was fixed. Can you check on that?
Posted by GregM on 3/7/2011 at 2:13 PM
In this case, the compiler can absolutely without a doubt 100% of the time deterministically figure out that PCH regeneration is needed. Notice that the error message says "No such file or directory". When I cancel the build while stdafx.cpp is being compiled, and a precompiled header is being created, then the precompiled header is properly deleted, because it wasn't finished, but the next time the build runs, it doesn't generate it. It seems that the compiler has recorded somewhere that it has already successfully generated the PCH, and so it doesn't need to do it. However, a simple check for file existence would tell it that the file is missing. The only way to get the compiler to realize that it needs to generate the PCH is to do a clean or rebuild.

Posted by Microsoft on 3/3/2011 at 3:26 PM

Thank you for reporting this. I understand the frustration when this happens, in most cases compiler should be able to deterministically figure out that regeneration of PCH is needed, however there are cases when it's not the case. A rerun of the incremental build could work. We'll consider this feature in a future release.

Ulzii Luvsanbat
Windows C++ Team
Posted by Microsoft on 2/7/2011 at 7:59 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(