我有一个简单的.IDL文件(iface.idl),它描述了一个基于IUnknown的接口:
importunknwn。 idl; [] [ uuid(80DFDD28-F033-431e-B027-CDD2078FC78A)] 接口ISunPathCalc:IUnknown { HRESULT Square([in,out] long * pVal ); HRESULT Cube([in,out] long * pVal); };尝试使用 midl / header iface.h iface.idl 我得到3个文件:iface.h,iface_i.c和iface_p.c。 iface.h文件包含ISunpathCalc接口的C ++声明:
#if defined(__ cplusplus)&& !defined(CINTERFACE) MIDL_INTERFACE(80DFDD28-F033-431e-B027-CDD2078FC78A) ISunPathCalc:public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE Square( / * [out] [in] * / long * pVal)= 0; virtual HRESULT STDMETHODCALLTYPE Cube( / * [out] [in] * / long * pVal)= 0; }; #else / * C style interface * /有没有办法告诉MIDL只生成标头的C ++部分? 是否可以关闭iface_i.c和iface_p.c文件的生成,并强制MIDL生成一个C ++定义?
UPD1 :
我尝试添加指定的[local]属性此处:
[ local, uuid(80DFDD28-F033-431e-B027-CDD2078FC78A)]不幸的是,没有办法抑制C头生成。
解决方案>
I have a simple .IDL file (iface.idl) which describes an IUnknown based interface:
import "unknwn.idl"; [ uuid(80DFDD28-F033-431e-B027-CDD2078FC78A) ] interface ISunPathCalc : IUnknown { HRESULT Square([in, out] long * pVal); HRESULT Cube([in, out] long * pVal); };When trying to compile it with midl /header iface.h iface.idl I'm getting 3 files: iface.h, iface_i.c and iface_p.c. The iface.h file contains a C++ declaration of ISunpathCalc interface:
#if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("80DFDD28-F033-431e-B027-CDD2078FC78A") ISunPathCalc : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE Square( /* [out][in] */ long *pVal) = 0; virtual HRESULT STDMETHODCALLTYPE Cube( /* [out][in] */ long *pVal) = 0; }; #else /* C style interface */The remaining larger part of this file contains needless C stuff.
Q: Is there way to tell MIDL to generate only C++ part of header? Is it possible to switch off generation of iface_i.c and iface_p.c files and to force MIDL to generate a C++ definition instead?
UPD1:
I tried to add [local] attribute as specified here:
[ local, uuid(80DFDD28-F033-431e-B027-CDD2078FC78A) ]but without any success.
解决方案Unfortunately there's no way of suppressing the C header generation.
更多推荐
有没有办法与MIDL关闭C风格头生成?
发布评论