有没有办法与MIDL关闭C风格头生成?

编程入门 行业动态 更新时间:2024-10-27 11:25:52
本文介绍了有没有办法与MIDL关闭C风格头生成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个简单的.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风格头生成?

本文发布于:2023-10-31 01:29:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544592.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有办法   风格   MIDL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!