{"id":5633,"date":"2007-06-27T13:04:00","date_gmt":"2007-06-27T13:04:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2007\/06\/27\/fixing-unsatisfied-forward-declaration-error-from-midl\/"},"modified":"2019-02-18T18:54:27","modified_gmt":"2019-02-18T18:54:27","slug":"fixing-unsatisfied-forward-declaration-error-from-midl","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/fixing-unsatisfied-forward-declaration-error-from-midl\/","title":{"rendered":"Fixing &#034;Unsatisfied forward declaration&#034; error from MIDL"},"content":{"rendered":"<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\">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.&nbsp; In case you run into the issue, here&#8217;s a brief description, along with what we did to work around it:<\/font><\/p>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\"><\/font>&nbsp;<\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\">In pseudo code, what the customer&nbsp;had looked like this:<\/font><\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\"><\/font>&nbsp;<\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\"><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" color=\"#1f497d\" size=\"2\"><span>#include &ldquo;MyInterfaceDefn.idl&rdquo;<\/span><\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" color=\"#1f497d\" size=\"2\"><span>interface MyInterface;<\/span><\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"calibri\" color=\"#1f497d\" size=\"2\"><span><\/span><\/font>&nbsp;<\/p>\n<p><\/font><\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\">Which parsed fine with the midl.exe included in Visual Studio 2005.&nbsp; However, building with Orcas, the customer&#8217;s code produced the following error:<\/font><\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\"><\/font>&nbsp;<\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\"><font face=\"Calibri\" color=\"#1f497d\" size=\"3\">MIDL2337 : unsatisfied forward declaration<\/font> and referenced the last line of code in the same scope as &#8220;i<font face=\"Calibri\" color=\"#1f497d\" size=\"2\"><span>nterface MyInterface;<\/span><\/font>&#8220;.&nbsp; <\/font><\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\"><\/font>&nbsp;<\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\">It turns out the&nbsp;customer defined MyInterface in <font face=\"Calibri\" color=\"#1f497d\" size=\"3\">MyInterfaceDefn.idl <font face=\"Tahoma\" color=\"#000000\" size=\"2\">and then put the declaration line&nbsp;right after the definition which, although worked fine in VS 2005, no longer is accepted by the new midl.exe.&nbsp; The solution turned out to be simple &#8211; just put the forward declaration before the definition and everything compiles fine:<\/font><\/font><\/font><\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\"><\/font>&nbsp;<\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\"><span>interface MyInterface;<\/span><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" color=\"#1f497d\" size=\"2\"><span>#include &ldquo;MyInterfaceDefn.idl&rdquo;<\/span><\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" color=\"#1f497d\" size=\"2\"><span><\/span><\/font>&nbsp;<\/p>\n<p><\/font><\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\">The customer&#8217;s code built an ran without any problems.&nbsp; Unfortunately, this was just one of those kind of idiosyncratic pieces of code that worked ok&nbsp;under the old idl compiler, but when the Windows tools teams updated midl, no longer went through ok.&nbsp; Luckily, the solution is trivial once you arrive at it.&nbsp; Hopefully if you hit the same issue, this blog entry will put you on your merry way!<\/font><\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\"><\/font>&nbsp;<\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\">Ben Anderson<\/font><\/div>\n<div dir=\"ltr\"><font face=\"tahoma\" size=\"2\">Visual C++ Libraries QA team<\/font><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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.&nbsp; In case you run into the issue, here&#8217;s a brief [&hellip;]<\/p>\n","protected":false},"author":289,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5633","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus"],"acf":[],"blog_post_summary":"<p>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.&nbsp; In case you run into the issue, here&#8217;s a brief [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/5633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/289"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=5633"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/5633\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=5633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=5633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=5633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}