开发者

MIDL compilation error (and maybe idl file generation question)

We're looking into moving our application from VS2008 to VS2010.

We generate some COM objects with "attributed programming" and the IDL is automatically generated.

The import directives for both files are different and the compilation fails on VS2010.

on VS2008, it generates something like :

import "docobj.idl";

on VS 2010

import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wincrypt.idl";
import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\exdisp.idl";
import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\shldisp.idl";
import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\prsht.idl";
import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\mshtmhst.idl";
import "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\mshtml.idl";
import "c:\program files (x86)\microsoft sdks\windows\v7.0a\include\dimm.idl";
import "c:\program files (x86)\microsoft sdks\windows\v7.0a\include\dispex.idl";

When the IDL is compiled on VS2010 it generates the following errors

20>  Microsoft (R) 32b/64b MIDL Compiler Version 7.00.0555 
20>  Copyright (c) Microsoft Corporation. All rights reserved.
20>  Processing .\_my_idl.idl
20>  _my_idl.idl
20>  Processing C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wincrypt.idl
20>  wincrypt.idl
20>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wincrypt.idl(47): error MIDL2025: syntax error : expecting a type specification or a storage specifer or a type qualifier near "WCHAR"
20>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wincrypt.idl(47): error MIDL2026: cannot recover from earlier syntax errors; aborting compilation
20>LINK : fatal error LNK1240: failed to compile IDL content

manually removing the "wincrypt.idl" import directive removes the compilation error, but that's not a solution since the idl is auto generated.

I'm not certain why the two IDL are 开发者_Go百科different and what is responsible to add the import directives; or even how to fix the MIDL compilation error.

Any ideas ?

Thanks in advance.

Max.


It is missing

 #import "ocidl.idl"

You could fix it by using the [importidl] attribute in your code.

Attributed programming was a bit of a mistake, it got essentially deprecated when it was removed as an option for the ATL Project wizard in VS2008. For long term maintenance of your code base consider removing it. You can use the auto-generated .idl as a way to get that started.


Perhaps I was using the [importidl] attribute wrong, but I couldn't get Hans' answer to fix this problem. But the fix here worked. Just add this to the top of your stdafx.h file:

[idl_quote("import \"ocidl.idl\";")];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜