16.19 The EXPORTS Statement

The EXPORTS statement defines the names and attributes of the functions and data made available to other applications and DLLs. It also defines the names and attributes 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 a section of export definitions. Multiple definitions must be separated by one or more spaces, tabs, or newline characters. 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 __export keyword makes a function available from a DLL.

Syntax

EXPORTS
entryname[[=internalname]] [[@ord[[ nametable]] ]] [[NODATA]]

Remarks

The entryname defines the function or data-item name as it is known to other programs. If the function or data item is in a C++ module, the entryname must be specified as a decorated name. For specific information on decorated names, see Appendix B.

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. The use of ord is faster and can save space.

The nametable is one of two optional keywords that determine what happens to entryname. By default, with or without ord, the entryname is placed in the nonresident names table. If the ord number is followed by RESIDENTNAME, the name is placed in the resident names table. If NONAME is specified after ord, the entryname is discarded from the DLL being created, and the item is exported only by ordinal.

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

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.

EXPORTS

SampleRead = read2bin @8

StringIn = str1 @4 RESIDENTNAME

CharTest