Quick start manual
Libraries and packages
9-5
Writing dynamically loadable libraries
Libraries can be built from multiple units. In this case, the library source file is
frequently reduced to a uses clause, an exports clause, and the initialization code. For
example,
library Editors;
uses EdInit, EdInOut, EdFormat, EdPrint;
exports
InitEditors,
DoneEditors name Done,
InsertText name Insert,
DeleteSelection name Delete,
FormatSelection,
PrintSelection name Print,
ƒ
SetErrorHandler;
begin
InitLibrary;
end.
You can put exports clauses in the interface or implementation section of a unit. Any
library that includes such a unit in its uses clause automatically exports the routines
listed the unit’s exports clauses—without the need for an exports clause of its own.
The directive local, which marks routines as unavailable for export, is platform-
specific and has no effect in Windows programming.
On Linux, the local directive provides a slight performance optimization for routines
that are compiled into a library but are not exported. This directive can be specified
for stand-alone procedures and functions, but not for methods. A routine declared
with local—for example,
function Contraband(I: Integer): Integer; local;
does not refresh the EBX register and hence
• cannot be exported from a library.
• cannot be declared in the interface section of a unit.
• cannot have its address taken or be assigned to a procedural-type variable.
• if it is a pure assembler routine, cannot be called from another unit unless the caller
sets up EBX.