### #pragma import (OS/2, Windows)

The #pragma import directive lets you import a function or a variable from a DLL using either an ordinal number or a name different from the one that it has in the DLL.

The identifier is the name you use in your source to refer to the function or variable. The external_name is the name of the function or variable in the DLL.

For C++ files, export_name can also be a function prototype. If export_name is not specified, it is assumed to be the same as identifier.

Note: Both identifier and export_name must be defined only once in each compilation unit.

The module is the name of the DLL containing the identifier, and ordinal indicates the position of the function or variable within the DLL.

The information provided by #pragma import is used at load time to locate the imported identifier. If ordinal is 0, the export_name is used to find the identifier. If ordinal is any other number, export_name is ignored and the identifier is located by number. It is usually faster to locate the identifier by number than by name.

Using #pragma import decreases your link time because the linker does not require an import library to resolve external names. This directive is also useful for C++ programming because you do not have to use the fully qualified name to refer to an imported function or variable.