Earlier this week I was helping a customer port some code from Visual Studio 2005 to a beta build of Orcas when we noticed an interesting change of behavior in how the new version of midl.exe (from the Windows Vista SDK release) was parsing code. In case you run into the issue, here’s a brief description, along with what we did to work around it:
In pseudo code, what the customer had looked like this:
Which parsed fine with the midl.exe included in Visual Studio 2005. However, building with Orcas, the customer’s code produced the following error:
MIDL2337 : unsatisfied forward declaration and referenced the last line of code in the same scope as “interface MyInterface;“.
It turns out the customer defined MyInterface in MyInterfaceDefn.idl and then put the declaration line right after the definition which, although worked fine in VS 2005, no longer is accepted by the new midl.exe. The solution turned out to be simple – just put the forward declaration before the definition and everything compiles fine:
The customer’s code built an ran without any problems. Unfortunately, this was just one of those kind of idiosyncratic pieces of code that worked ok under the old idl compiler, but when the Windows tools teams updated midl, no longer went through ok. Luckily, the solution is trivial once you arrive at it. Hopefully if you hit the same issue, this blog entry will put you on your merry way!
Visual C++ Libraries QA team