The mktyplib203 Option

The MIDL compiler behaves differently from the now unsupported MkTypLib utility. The /mktyplib203 option removes most of these differences and makes MIDL act like MkTypLib did, version 2.03.

For example, BOOL (a MkTypLib base type) is defined differently in MIDL than it was in MkTypLib. MkTypLib treated BOOL as a VARIANT_BOOL. However, BOOL is defined in the file Wtypes.idl as a long data type. If a VARIANT_BOOL is to be placed in the type library, it has to explicitly use VARIANT_BOOL in the .idl/.odl file. If BOOL is used when VARIANT_BOOL is meant to be used, then the /mktyplib203 option should also be used.

MIDL normally puts globally unique identifier (GUID) predefinitions in its generated header files, and only puts GUID instantiations in the file generated by the /iid option. With the /mktyplib203 option, MIDL defines GUIDs in the header files in the way that MkTypLib did. They are defined with a macro that can be compiled conditionally to generate either a predefined or an instantiated GUID.

With the /mktyplib203 option enabled, it is invalid to put any statements outside of the library block. A pure ODL syntax must be used; it cannot be mixed and matched in this mode.

MkTypLib is used to require struct, union, and enum to be defined as part of type definitions. For example:

typedef struct myStruct { int i; } testStruct;

In this statement, MkTypLib generates a TKIND_RECORD named "testStruct." Because the "myStruct" was not recorded anywhere in the type library, it can be omitted.

MIDL allows normal C definitions of structure, union, and enum:

struct myStruct {int i;};
   typedef struct myStruct testStruct;

– Or –

   typedef struct myStruct {int i;} testStruct;

This statement generates a TKIND_RECORD named "myStruct" and (if the type definition is public) a TKIND_ALIAS named "testStruct." The "myStruct" can still be omitted, in which case MIDL generates a name for it.

When the /mktyplib203 option is enabled, the original MkTypLib type definition syntax is required for structures, unions, and enumerators. The behavior is the same as it was under MkTypLib (that is, "myStruct" is not included in the type library).

Note

MkTypLib permitted some scoping errors, such as giving enumerators their own scope. These errors are fixed by MIDL, and cannot be reintroduced, even with the /mktyplib203 switch. Even though the /mktyplib203 switch enables MIDL to compile most earlier .odl files, there can be a few exceptions. These are cases where the .odl files were already broken, and MkTypLib did not catch the errors.