13.17 The EXPORTS Statement

The EXPORTS statement defines the names and attributes of the functions and data made available to other applications and DLLs, and of the functions that run with I/O privilege. By default, functions and data are hidden from other programs at run time. A definition is required for each function or data item being exported.

The EXPORTS keyword marks the beginning of the export definitions, each on its own line. The EXPORTS keyword must appear once before the first definition (on the same or preceding line) and can be repeated before each additional definition. EXPORTS statements can appear more than once in the file.

Some languages offer a way to export without using an EXPORTS statement. For example, in C the _exports keyword makes a function available from a DLL.

Syntax

EXPORTS
entryname[[=internalname]] [[@ord[[ RESIDENTNAME]] ]] [[NODATA]] [[pwords]]

Remarks

The entryname defines the function or data-item name as it is known to other programs. The optional internalname defines the actual name of the exported function or data item as it appears within the exporting program; by default, this name is the same as entryname.

The optional ord field defines a function's ordinal position within the module-definition table as an integer from 1 to 65,535. If ord is specified, the function can be called by either entryname or ord. Use of ord is faster and can save space.

The optional keyword RESIDENTNAME specifies that entryname be kept resident in memory at all times. This keyword is applicable only if ord is used. (If ord is not used, the name entryname is always kept in memory.)

The optional keyword NODATA specifies that there is no static data in the function.

The pwords field specifies the total size of the function's parameters in words. This field is required only if the function executes with I/O privilege. When a function with I/O privilege is called, OS/2 consults pwords to determine how many words to copy from the caller's stack to the I/O-privileged function's stack.

Example

The following EXPORTS statement defines the three exported functions SampleRead, StringIn, and CharTest. The first two functions can be called either by their exported names or by an ordinal number. In the application or DLL where they are defined, these functions are named read2bin and str1, respectively. The first and last functions run with I/O privilege and therefore are given with the total size of the parameters.

EXPORTS

SampleRead = read2bin @8 24

StringIn = str1 @4 RESIDENTNAME

CharTest 6