meissnersd
meissnersd

Reputation: 1312

wrong windows.h when migrating from VS 2005 to VS 2012

I have a bunch of VS C++ 2005 desktop applications. We are migrating some of them to VS 2012. Some of the legacy applications we intend to leave in 2005. So we would like the two applications to build side by side, one in VS 2012 and the other in VS 2005.

I am having trouble with my VS 2012 projects including the wrong Windows.h in VS 2012. My migrated projects get the wrong includes. I thought it was project specific, but if I just make a defaut MFC project in the VS 2012 New Project wizard, it is getting the wrong Windows.H. So thats just a stock project purely generated by VS 2012. It should just build out of the box.

How do I get the correct windows.h? How do I maintain the ability to build side by side VS 2005 and VS 2012 on the same machine.

Here is the error message

1>------ Rebuild All started: Project: includeWinH, Configuration: Debug Win32 ------ 1> stdafx.cpp 1>c:\program files (x86)\microsoft visual studio 8\vc\platformsdk\include\specstrings.h(491): warning C4005: '_ecount' : macro redefinition 1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\sal.h(2651) : see previous definition of '_ecount' 1>c:\program files (x86)\microsoft visual studio 8\vc\platformsdk\include\specstrings.h(492): warning C4005: '_bcount' : macro redefinition 1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\sal.h(2652) : see previous definition of '_bcount'

Upvotes: 1

Views: 672

Answers (2)

Florian Winter
Florian Winter

Reputation: 5329

Microsoft removed the library/include directory settings from the Visual Studio settings and encouraged users to use property sheets instead.

However, they also introduced a "secret" property sheet called Microsoft.Cpp.Win32.user which is added to every project in Visual Studio 2012, even new ones that were not migrated from older versions of Visual Studio. If Visual Studio 2008 or older was previously installed on the machine, then this property sheet contains the library/include directory settings of the older version of Visual Studio.

Basically, Microsoft.Cpp.Win32.user is the same as the old library/include directory settings, except it is harder to find.

I would recommend the following:

  • Restore all settings in this file to the defaults, particularly stale references to old Windows/platform SDKs

  • Remove this property sheet from every configuration in every project, so it doesn't cause problems on other people's machines

More information: http://msdn.microsoft.com/en-us/library/669zx6zc.aspx

Upvotes: 0

meissnersd
meissnersd

Reputation: 1312

Some how in the course of installing and migrating, VS2012 copied in some settings from VS 2005. The fix was in VS 2012

Open Property Manager
Open Microfoft.Cpp.Win32.user right click menu 'Properties'
edit Common Properties->VC++ Directories->Include Directories
remove the stale references to VS2005 dir. 

Upvotes: 1

Related Questions