MIDL changes case of identifier when compiling IDL file

守給你的承諾、 提交于 2019-12-10 14:34:07

问题


I've got a snippet of IDL that looks like this:

[ object, uuid(...), pointer_default(unique) ]
interface IVirtualMachine { /* ... */ }

[ object, uuid(...), pointer_default(unique) ]
interface IVirtualServer : IUnknown
{
    HRESULT FindVirtualMachine(
        [in] BSTR configurationName,
        [out,retval] IVirtualMachine **virtualMachine);
};

[ uuid(...), version(1.0) ]
library VirtualServerLib
{
    [ uuid(...) ]
    coclass VirtualServer
    {
        [default] interface IVirtualServer;
    };

    [ uuid(...) ]
    coclass VirtualMachine
    {
        [default] interface IVirtualMachine;
    };
};

...when I compile it with MIDL and then look in the generated type library, VirtualMachine (upper-case V) has been turned into virtualMachine (lower-case V).

If I call my coclass XirtualMachine, for example, it's all good.

What the hell?


回答1:


This is a terrible bug/feature of MIDL. It doesn't allow the same identifier to appear with different casing, so it replaces all subsequent instances of a word with the casing from the first time it was seen.

See the KB220137




回答2:


OK. Worked it out. It was this line here:

[out,retval] IVirtualMachine **virtualMachine);

If I change it to:

[out,retval] IVirtualMachine **ppVirtualMachine);

...then it works fine. Something screwy in MIDL, I guess. Maybe it's trying to do VB-like case correction.



来源:https://stackoverflow.com/questions/1278166/midl-changes-case-of-identifier-when-compiling-idl-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!