Module Definition File

The module definition file is a simple text file required by most Presentation Manager applications. Module definition files are used when link editing both programs and dynamic link libraries. By convention, the module definition file has the same name as the program or library source file, but with an extension of DEF.

A sample module definition file for a simple Presentation Manager application is shown in Figure "Sample Module Definition File for Presentation Manager."

A module definition file normally begins with a NAME or LIBRARY statement, which identifies the module as a program or DLL respectively, and assigns it a module name. The keyword WINDOWCOMPAT may be used to specify a full-screen application that may be run in a Presentation Manager text window, or WINDOWAPI may be used to specify a full Presentation Manager application.

The module definition file also contains a DESCRIPTION entry, containing text that is embedded by the link editor into the header of the executable module. This text may contain information such as a copyright notice or author information concerning the module.

The PROTMODE keyword should be used to indicate that the application will be run only in protect mode under OS/2 (note that this is a standard provision; all Presentation Manager applications must run in protect mode). This allows the link editor to shorten the header in the executable module.

The STUB keyword instructs the link editor to set up a stub file that generates an error message if the user attempts to execute the application in a DOS environment. OS2STUB.EXE is a DOS executable file that performs this function, and is provided with the IBM Developer's Toolkit for OS/2 2.0.

A DATA statement may be used in the module definition file to indicate the disposition of data segments created by the module. Data segments may be specified as SHARED, NONSHARED or NONE. If SHARED is specified, different processes using the code segments of a dynamic link library will share the same data segments; if NONSHARED is specified, the operating system will create a new set of data segments for each process using a DLL. NONSHARED is recommended.

The STACKSIZE and HEAPSIZE statements specify the size of the memory areas to be reserved for the application's stack and for the local heap in the program's automatic data segment. Note that the recommended minimum stack size for Presentation Manager applications is 8 KB. Note also that STACKSIZE is not used for dynamic link library modules, since a DLL has no stack (see Creating a DLL).

The module definition file may also contain an EXPORTS statement for all exportable entry points (such as window procedures) window procedures contained in the module. This statement causes the entry points for window procedures to be defined in the header of an executable module, so that they may later be called from outside the current executable module (since window procedures are actually invoked by Presentation Manager on behalf of the application, rather than directly by the application itself).

An IMPORTS statement may be used to define the entry points for those functions and/or resource definitions that will be imported from a dynamic link library. However, an IMPORTS statement is not required if an import library is being link edited with the application (see Using a DLL).

The module definition file, and the statements it may contain, are described fully in the IBM OS/2 Version 2.0 Application Design Guide.


[Back: Compiling C Source Code]
[Next: Compiler Options]