Is there a way with MIDL to turn off C-style heade

2019-07-16 21:09发布

问题:

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.

回答1:

Unfortunately there's no way of suppressing the C header generation.



标签: c++ com idl midl