问题
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);
回答1:
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
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, 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.
回答2:
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;
来源:https://stackoverflow.com/questions/431206/no-type-definitions-in-pre-defined-idl-file