tags:

views:

93

answers:

2

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?

A: 

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.

Roger Lipscombe
+2  A: 

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

Sam
Finding the relevant KB: good spot.
Roger Lipscombe