预定义的 IDL 文件中没有类型定义
首先,
使用plain C++,没有ATL,MFC尝试使用COM Object接口。
使用 oleview(OLE/COM 对象查看器)- 用于设计 IDL 代码。
在此阶段,使用 MIDL 编译器,现在我在尝试生成以下内容时遇到了麻烦:
cmd 行语法:
midl /nologo /env win32 /tlb ".\S8_.tlb" /h " .\S8_.h" /iid ".\S8_i.c" S8.idl
- 对应的.TLB(类型库)
- A.H(标头)
- IID 定义包含文件 (*_i.c)
- 代理 (*_p.c)
MIDL 编译器错误:
S8.IDL(513):错误 MIDL2025:语法错误:期望“S8SimObject”附近有类型规范
HRESULT LinkSimObjects(
[in] S8SimObject* SourceObject, ####line 513 ####
[in] S8SimObject* DestObject,
[in] float TravelTime);
Firstly,
Using plain C++, without ATL, MFC attempting to use COM Object interface.
Using oleview (OLE/COM Object viewer) - used to engineer the IDL code.
At this stage, using MIDL Compiler, now I'm having trouble trying to produce the following:
Syntax on cmd line:
midl /nologo /env win32 /tlb ".\S8_.tlb" /h ".\S8_.h" /iid ".\S8_i.c" S8.idl
- A corresponding .TLB (Type Library)
- A .H (header)
- An IID definitions include file (*_i.c)
- A proxy (*_p.c)
MIDL compiler error:
S8.IDL(513) : error MIDL2025 : syntax error : expecting a type specification near "S8SimObject"
HRESULT LinkSimObjects(
[in] S8SimObject* SourceObject, ####line 513 ####
[in] S8SimObject* DestObject,
[in] float TravelTime);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我不太明白你的问题,但以下内容应该有所帮助:
short
通常表示短整数,而不是单精度浮点数。float
的等价物是single
,但正如我在您的其他问题中看到的那样,我怀疑您实际上的意思是将single
替换为浮动
。顺便说一句,我建议发布一个最小的(可编译的)IDL 文件(删除了大多数定义),它或多或少类似于您要编译的文件。 这有助于避免一些混乱,例如您在文本中使用
IS8Simulation
,但在复制的 IDL 代码段中使用S8SimObject
。 如果您指定预期的结果和意外的(对您来说)错误也会有所帮助。编辑
那么,您现在插入的这个编译错误很简单:
S8SimObject
未定义。 您需要始终在方法声明 (IS8Simulation
) 中引用接口,而不是实现该接口的组件类。正如您所说,您正在此处更改现有的 IDL 文件:基本目标是什么? 如果原始IDL文件总是使用
S8SimObject
,也许唯一的问题是S8SimObject
的定义没有包含在IDL文件的顶部? 如果您有定义S8SimObject
的类型库,则可以使用 OleView 导出此接口的 IDL。Well, I do not really understand your question here, but following should help:
short
usually means a short integer, not a single-precision floating-point number.float
issingle
in VB, but as I've seen on other questions of you, I suspect you actually meant replacingsingle
withfloat
.By the way, I'd recommend to post one minimal (compilable) IDL file (stripped of most definitions), which resembles more or less what you're trying to compile. This helps against some confusion, as you're for instance using
IS8Simulation
in your text, butS8SimObject
in your copied IDL snippet. And it would also help if you specify the expected result, and the unexpected (for you) error.Edit
Well, this compile error you now inserted is simple:
S8SimObject
is not defined. You need to always refer to the interface in the method declarations (IS8Simulation
), never to the coclass which implements the interface.As you said you're changing an existing IDL file here: What is the basic goal? If the original IDL file always uses
S8SimObject
, maybe the only problem is that the definition ofS8SimObject
is not included at the top of the IDL file? If you've the type-library definingS8SimObject
around, you can export the IDL of this interface by using OleView.MIDL 编译器错误
S8.IDL(513):错误 MIDL2025:语法错误:期望 "S8SimObject" 附近有类型规范
已解决
添加前向声明 - 在 IDL 文件的顶部:
MIDL compiler error
S8.IDL(513) : error MIDL2025 : syntax error : expecting a type specification near "S8SimObject"
SOLVED
Add a forward declaration - at the TOP of IDL file: