ODL File Syntax

The general syntax for an .odl file is as follows:

[attributes] library libname {definitions};

The attributes associate characteristics with the library, such as its Help file and universally unique identifier (UUID). Attributes must be enclosed in square brackets.

The definitions consist of the descriptions of the imported libraries, data types, modules, interfaces, dispinterfaces, and coclasses that are part of the type library. Braces ({}) must surround the definitions.

The following table summarizes the elements that can appear in definitions. Each element is described in more detail later in this chapter, in the section "ODL Reference."

Purpose Library element Description
Allows references to other type libraries. importlib (lib1) Specifies an external type library that contains definitions that are referenced in this type library.
Declares data types used by the objects in this type library. typedef [attributes] aliasname An alias declared using C syntax. Must have at least one attribute to be included in the type library.
typedef [attributes] enum An enumeration declared using the C keywords typedef and enum.
typedef [attributes] struct A structure declared using the C keywords typedef and struct.
typedef [attributes] union A union declared using the C keywords typedef and union.
Describes functions that enable querying the DLL. [attributes] module Constants and general data functions whose actions are not restricted to any specified class of objects.
Describes interfaces.
[attributes] dispinterface An interface describing the methods and properties for an object that must be accessed through IDispatch::Invoke.
[attributes]
interface
An interface describing the methods and properties for an object that can be accessed either through IDispatch::Invoke or through VTBL entries.
Describes OLE classes. [attributes] coclass Specifies a top-level object with all of its interfaces and dispinterfaces.

In the library description, modules, interfaces, dispinterfaces, and coclasses follow the same general syntax:

[attributes] elementname typename {
    memberdescriptions
};

The attributes set characteristics for the element. The elementname is a keyword that indicates the kind of item (module, interface, dispinterface, or coclass), and the typename defines the name of the item. The memberdescriptions define the members (constants, functions, properties, and methods) of each element.

Aliases, enumerations, unions, and structures have the following syntax:

typedef [typeattributes] typekind typename {
    memberdescriptions
};

For these types, the attributes follow the typedef keyword, and the typekind indicates the data type (enum, union, or struct). For details, see "Attribute Descriptions" later in this chapter.

Note The square brackets ([ ])and braces ({ }) in these descriptions are part of the syntax, and are not descriptive symbols. The semicolon after the closing brace (}) that terminates the library definition (and all other type definitions) is optional.