问题使用Midl从.idl创建.tlb“期望类型规范” [英] Issues Using Midl to create a .tlb from .idl "expecting a type specification"

查看:451
本文介绍了问题使用Midl从.idl创建.tlb“期望类型规范”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在与被称为COM互操作的野兽长时间的遭遇...

I have been having a prolonged encounter with the beast known as COM Interop...

我目前正在尝试从.idl文件生成.tlb生成通过OLE / COM对象查看器。但是,当试图运行Midl.exe编译它时,我得到一个错误:

I am currently trying to generate a .tlb from a .idl file generated by the OLE/COM Object Viewer. However when trying to run Midl.exe to compile it I get an error:

.\Sim.API.IDL(236) : error MIDL2025 : syntax error : expecting a type s
pecification near "ImportFileStatus"

我的.idl文件是多1000行长,所以我不特别想要在这里发布,但我相信部分感兴趣的是:

My .idl file is more that 1000 lines long so I don't particularly want to post it here however, I believe the Part of interest is:

typedef [uuid(980B172E-19C1-389A-BB74-29A54737C5B4), version(1.0)    ,
  custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "Sim.API.ImportFileResult")    
 ]
 struct tagImportFileResult {

  ImportFileStatus _status;

  LPSTR _message;
 } ImportFileResult;

然后几行...

 typedef [uuid(A4B9A0FF-A2D4-3EC5-AB7E-69311B9122C8), version(1.0)    ,
  custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "Sim.API.ImportFileStatus")    
 ]
 enum {
  ImportFileStatus_Success = 0,
  ImportFileStatus_VersionMismatch = 1,
  ImportFileStatus_Failure = 2
 } ImportFileStatus;

我有一个感觉,这些应该被尊重以修复类型规范错误。

I have a Feeling that these should be revered in order to fix the Type specification error. However if I do this I get a new problem.

midl\oleaut32.dll : warning MIDL2368 : error generating type library, ignored :
Could not set UUID : tagImportFileResult (0x800288C6)

idl格式和使用midl.exe,也许有一些明显错了我正在做什么?

I am pretty unfamiliar with the idl format and with the use of midl.exe, perhaps there is something blatantly wrong with what I am doing?

一如既往任何帮助将非常感激:)


As always any help would be greatly appreciated :)

推荐答案

你是正确的,交换声明是保持MIDL快乐所必需的。 OleView.exe确实不会生成声明的原始顺序。我认为它是按种类,组织类型lib的方式组织它们。

You are correct, swapping the declarations is required to keep MIDL happy. OleView.exe indeed won't generate declarations in the original order. I think it groups them by kind, the way the type lib is organized.

你得到的消息只是一个警告,而不是错误。它是由不同的结构名称的别名引起的。你可以安全地忽略它,因为代码不会使用tagImportFileResult标识符。但你可以通过使标签名称与typedef名称相同:

The message you are getting is just a warning, not an error. It is caused by having an alias for the structure name that's different. You can safely ignore it because code won't use the "tagImportFileResult" identifier. But you can get rid of it by making the tag name the same as the typedef name:

typedef [..] 
   struct ImportFileResult {
   //...
} ImportFileResult;

这是一个知识库文章

这篇关于问题使用Midl从.idl创建.tlb“期望类型规范”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆