next up previous contents index search.gif
Next: 10. Exceptions Up: 9. Programs, units, blocks Previous: 9.4 Scope

9.5 Libraries

Free Pascal supports making of dynamic libraries (DLLs under Windows) trough the use of the Library keyword.

A Library is just like a unit or a program:


Libraries

\begin{syntdiag}\setlength {\sdmidskip}{.5em}\sffamily\sloppy \synt{library}
\sy...
...playmath}\synt{uses\ clause} \end{displaymath}\synt{block}
\lit* .\end{syntdiag}

\begin{syntdiag}\setlength {\sdmidskip}{.5em}\sffamily\sloppy \synt{library\ header}
\lit*{library} \synt{identifier}\end{syntdiag}
By default, functions and procedures that are declared and implemented in library are not available to a programmer that wishes to use your library.

In order to make functions or procedures available from the library, you must export them in an export clause:


Exports clause

\begin{syntdiag}\setlength {\sdmidskip}{.5em}\sffamily\sloppy \synt{exports\ clause}
\lit*{exports}
\synt{exports\ list}
\lit*{;}\end{syntdiag}

\begin{syntdiag}\setlength {\sdmidskip}{.5em}\sffamily\sloppy \synt{exports\ list}
\<[b] \synt{exports\ entry} \\ \lit* , \>\end{syntdiag}

\begin{syntdiag}\setlength {\sdmidskip}{.5em}\sffamily\sloppy \synt{exports\ ent...
...{displaymath}\lit*{name} \synt{string\ constant} \end{displaymath}\end{syntdiag}
Under WINDOWS NT, an index clause can be added to an exports entry. an index entry must be a positive number larger or equal than 1. It is best to use low index values, although nothing forces you to do this.

Optionally, an exports entry can have a name specifier. If present, the name specifier gives the exavt name (case sensitive) of the function in the library.

If neither of these constructs is present, the functions or procedures are exported with the exact names as specified in the exports clause.



root
1999-06-10