MIDL编译错误(也许是idl文件生成问题)

发布于 2024-09-10 15:57:40 字数 1843 浏览 5 评论 0 原文

我们正在考虑将我们的应用程序从 VS2008 迁移到 VS2010。

我们用“属性编程”生成一些COM对象,IDL就自动生成了。

两个文件的导入指令不同,在 VS2010 上编译失败。

在 VS2008 上,它会生成类似以下内容的内容:

import "docobj.idl";

在 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";

当在 VS2010 上编译 IDL 时,它会生成以下错误,

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

手动删除“wincrypt.idl”导入指令会删除编译错误,但这不是解决方案,因为 idl 是自动生成的。

我不确定为什么两个 IDL 不同以及负责添加导入指令的是什么;甚至如何修复 MIDL 编译错误。

有什么想法吗?

提前致谢。

最大限度。

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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

内心荒芜 2024-09-17 15:57:40

它丢失了

 #import "ocidl.idl"

您可以通过在代码中使用 [importidl] 属性来修复它。

属性编程是一个有点错误,当它作为 VS2008 中 ATL 项目向导的一个选项被删除时,它基本上被弃用了。为了长期维护您的代码库,请考虑将其删除。您可以使用自动生成的 .idl 作为开始的方式。

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.

风吹短裙飘 2024-09-17 15:57:40

也许我错误地使用了 [importidl] 属性,但我无法得到 Hans 的答案来解决这个问题。但修复这里起作用了。只需将其添加到 stdafx.h 文件的顶部:

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

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\";")];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文