Typedef Syntax for Complex Data Types

In MkTypLib, both of the following definitions generate a TKIND_RECORD for "bar" in the type library. The tag "foo" is optional and, if used, will not show up in the type library.

typedef struct foo { ... } bar;

typedef struct { ... } bar;

In MIDL, the first definition will generate a TKIND_RECORD for "foo" and a TKIND_ALIAS for "bar" (defining "bar" as an alias for "foo"). For the second definition, MIDL will generate a TKIND_RECORD for a mangled name internal to MIDL that is not meaningful to the user and a TKIND_ALIAS for "bar". This has potential implications for type library browsers that simply show the name of a record in its user interface. If you expect a TKIND_RECORD to have a real name, there is a potential for unrecognizable names to appear in the user interface. This behavior also applies to union and enum definitions, with the MIDL compiler generating TKIND_UNIONs and TKIND_ENUMs, respectively.

MIDL also allows C-style struct, union and enum definitions. For example, the following definition is legal in MIDL:

struct foo { ... };

typedef struct foo bar;