Name
External Directive
Syntax
subroutine declaration; external;subroutine declaration; externalDllName;subroutine declaration; externalDllNamenameString;subroutine declaration; externalDllNameindexConstant;
Description
Every subroutine declared in a unit’s
interface section must be implemented in the same
unit’s implementation section. Subroutines
can be implemented with the external directive,
which means the actual implementation is in a separate object file or
DLL. If no DllName is given, the external
implementation must be linked from a compatible object file using the
$L or $Link compiler
directive.
A DllName must be a string constant. For
maximum portability, be sure to include the .dll
extension in the DLL’s filename. (Windows NT, for example,
requires the file’s extension.) By default, Delphi looks up the
subroutine name in the DLL, but you can specify a different name to
look up or specify a numeric index.
Example
// Import the debugging procedures that were exported from
// the Debug library. (See the Exports Directive.)
procedure Log(const Msg: string); overload; external 'Debug.dll';
procedure Log(const Fmt: string; const Args: array of const); overload;
external 'Debug.dll' name 'LogFmt';See Also
| Exports Directive, Index Directive, Name Directive, $L Compiler Directive, $Link Compiler Directive |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access