Tag Archives: C++

Unexpected precompiled header error C1859 on Windows 7

I’m one of the few developers at my company that is using Windows 7.  Most of the projects in the solution I am working with are C#, but some are C++.  Periodically I get the following error building every single source file in the C++ project on my machine:

fatal error C1859: 'Debug\MyProject.pch' unexpected precompiled header error, simply rerunning the compiler might fix this problem

Nothing I did seemed to solve the problem short of rebooting, which seems to be a common experience (see here and here).  Today I stumbled upon a post on the Visual C++ Team Blog that explains what is going on.

It turns out that the anti-malware improvements in Windows 7 are the culprit.  PCH files are implemented basically as a memory dump, including pointers.  This worked fine on previous versions of Windows, but Windows 7 upped the ante making this approach unworkable.

The new behavior that fixes this problem is available in Visual Studio 2010.  The Visual C++ team has also released a hotfix for Visual Studio 2008 SP1 with the fix.

Resources