The MIDL compiler behaves differently from the MkTypLib utility. The /mktyplib203 option removes most of these differences and makes MIDL act like MkTypLib, version 2.03.
For example, BOOL (a MkTypLib base type) is defined differently in MIDL than it is in MkTypLib. MkTypLib treats 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 does. 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 foo { int i; } bar;
In this statement, MkTypLib generates a TKIND_RECORD named "bar." Because the "foo" was not recorded anywhere in the type library, it can be omitted.
MIDL allows normal C definitions of structure, union, and enum:
struct foo {int i;};
typedef struct foo bar;
– Or –
typedef struct foo {int i;} bar;
This statement generates a TKIND_RECORD named "foo" and (if the type definition is public) a TKIND_ALIAS named "bar." The "foo" 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 under MkTypLib (that is, "foo" is not included in the type library).
Note MkTypLib permits 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.