预定义的 IDL 文件中没有类型定义

发布于 2024-07-12 02:25:52 字数 690 浏览 10 评论 0原文

首先,

使用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 技术交流群。

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

发布评论

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

评论(2

巡山小妖精 2024-07-19 02:25:52

好吧,我不太明白你的问题,但以下内容应该有所帮助:

  • 公共枚举定义需要有自己的uuid才能真正公开。
  • 我已经看到这些枚举定义不会进入类型库,除非它们实际在某些接口方法中使用。 我不知道这样做的原因,可能我错过了一些简单的事情(比如将该枚举添加到库块中,或者其他什么)。
  • short 通常表示短整数,而不是单精度浮点数。
  • 在 VB 中,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:

  • Public enum definitions need to have their own uuid to be really public.
  • I've seen that those enum definitions don't go into the type-library unless they are actually used in some interface method. I do not know the reason for this, probably I missed something simple (like adding that enum to a library block, or whatever).
  • short usually means a short integer, not a single-precision floating-point number.
  • The equivalent of float is single in VB, but as I've seen on other questions of you, I suspect you actually meant replacing single with float.

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, but S8SimObject 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 of S8SimObject is not included at the top of the IDL file? If you've the type-library defining S8SimObject around, you can export the IDL of this interface by using OleView.

烟酒忠诚 2024-07-19 02:25:52

MIDL 编译器错误

S8.IDL(513):错误 MIDL2025:语法错误:期望 "S8SimObject" 附近有类型规范

已解决

添加前向声明 - 在 IDL 文件的顶部:

  • 导入“ocidl.idl”;
  • 接口S8SimObject;

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:

  • import "ocidl.idl";
  • interface S8SimObject;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文