You are currently offline, waiting for your internet to reconnect

MIDL changes the case of identifier in generated type library

This article was previously published under Q220137
When there are two identifiers that differ only by case, the case of the second identifier is changed to reflect the case of the first.
The IDL and Type library are not case sensitive by design. The Ole Automation code that is called by MIDL to generate the type library is taking the first occurrence of a name and any subsequent occurrences of the same name in the IDL, even if it is in different context, to be the same.
The following are workarounds you can use to avoid this problem:
  • In the case of importing one IDL file to another, the possibility of this happening is higher. Instead of importing IDL files into another IDL, import a corresponding type library.
  • Make sure that the same name is not already present in the IDL file when introducing a new identifier.
  • Map the identifier generated in the type library with the Components documentation. This is really not too difficult since any identifiers that differ only by case will be in a different context that is, one a method and another a parameter, structure and so forth. This will help to avoid discrepancy in component documentation.
This behavior is by design.
If an IDL file has two different identifiers with the same name but differ only in the case, then the MIDL generated Type Library will change the second identifier to the same case as the first one.

Steps to reproduce behavior

  1. Create an IDL file (name.idl). See the following example:
    // Test program to demonstrate capitalization bugs in MIDL 5.02.0235import "oaidl.idl";import "ocidl.idl";   [      uuid(DB9DDB0D-8834-11D1-8278-00A024A41CC8),      dual,      oleautomation,   ]   interface Interface1 : IDispatch {      [ id(4), helpstring("") ]      HRESULT OtherMethod (         // This parm name will affect the case of the subsequent method name.         [in] VARIANT_BOOL mYnAme );   };   [      uuid(DB9DDB0C-8834-11D1-8278-00A024A41CC8),      dual,      oleautomation,   ]   interface Interface2 : IDispatch {      [ id(5), helpstring("") ]      // The method name gets changed.      HRESULT MyName ();   };[  uuid(2A216780-BC52-11D2-B94F-00C04F81B63A), version(1.0),]library MIDLTST{   importlib("stdole32.tlb");   [      uuid(65B5C950-883D-11D1-8278-00A024A41CC8),      helpstring("Exercise various supported types.")   ]   coclass MIDLTest {      [default] interface Interface1;      interface Interface2;   };};						
  2. Use MIDL compiler to generate Type Library. Use the command MIDL name.idl
  3. Open the generated Type library in OLEVIEW. See the following OLEVIEW output.
    // Generated .IDL file (by the OLE/COM Object Viewer)// // typelib filename: <could not determine filename>[  uuid(2A216780-BC52-11D2-B94F-00C04F81B63A),  version(1.0)]library MIDLTST{    // TLib :     // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}    importlib("STDOLE2.TLB");    // Forward declare all types defined in this typelib    interface Interface1;    interface Interface2;    [      uuid(65B5C950-883D-11D1-8278-00A024A41CC8),      helpstring("Exercise various supported types.")    ]    coclass MIDLTest {        [default] interface Interface1;        interface Interface2;    };    [      odl,      uuid(DB9DDB0D-8834-11D1-8278-00A024A41CC8),      dual,      oleautomation    ]    interface Interface1 : IDispatch {        [id(0x00000004)]        HRESULT OtherMethod([in] VARIANT_BOOL mYnAme);    };    [      odl,      uuid(DB9DDB0C-8834-11D1-8278-00A024A41CC8),      dual,      oleautomation    ]    interface Interface2 : IDispatch {        [id(0x00000005)]        HRESULT mYnAme();    };};						
  4. Here the method name MyName in Interface2 has been changed to mYnAme.
MIDL TypeLib oleprog

Article ID: 220137 - Last Review: 09/29/2006 17:47:01 - Revision: 2.3

  • Microsoft Platform Software Development Kit-January 2000 Edition
  • kbbug kbpending KB220137