c++mfcvisual-studio-2013midlvcproj

Visual studio 2013 project with v120_xp toolset has MIDL 2072 error


I have recently moved to visual studio 2013 and upgrade all my c++ projects to use 8.1 of the windows SDK and the v120_xp toolset. A large majority of the projects are compiling and working fine i do however have two projects that refuse to build with several errors similar to the following error:

error MIDL2072: inapplicable attribute : [annotation] [ Field 'pDescription' of Struct 'D3D10_MESSAGE' ( Type 'D3D10_MESSAGE' ) ]

All the errors refer to the d3d10sdklayers.idl file. This occurs when the projects idl file is compiled as part of the project if i compile the file alone its fine.

Any help or suggestions are appreciated, thanks.


Solution

  • and upgrade all my c++ projects to use 8.1 of the windows SDK

    That's where that went wrong. When you use the v120_xp toolset then you use an old version of the Windows SDK. Version 7.1, the last one that's still compatible with XP. With #include files that are different, and build tools like midl.exe that are older.

    You cannot use this old version of midl.exe on the 8.1 version of d3d10sdklayers.idl. It contains attributes that it doesn't know how to process. It chokes on the _Field_size_(DescriptionByteLength) that's present in that file. Only the 8.x version of midl.exe can deal with it.

    You are kinda lucky to run into this problem, there are a lot more hidden traps in the 8.1 SDK headers that will make your program fail to work properly on XP. Pretty hard to diagnose too. If you require XP compatibility then you must use the 7.1 headers. You'll have to fix to the damage you did to the projects, presumably the VC++ Directories settings. Or give up on supporting XP, the time has come.