summaryrefslogtreecommitdiffstats
path: root/doc/load.n
diff options
context:
space:
mode:
Diffstat (limited to 'doc/load.n')
-rw-r--r--doc/load.n55
1 files changed, 38 insertions, 17 deletions
diff --git a/doc/load.n b/doc/load.n
index e5501f6..350a2ae 100644
--- a/doc/load.n
+++ b/doc/load.n
@@ -11,13 +11,12 @@
.SH NAME
load \- Load machine code and initialize new commands
.SH SYNOPSIS
-\fBload \fIfileName\fR
+\fBload\fR ?\fB\-global\fR? ?\fB\-lazy\fR? ?\fB\-\-\fR? \fIfileName\fR
.br
-\fBload \fIfileName packageName\fR
+\fBload\fR ?\fB\-global\fR? ?\fB\-lazy\fR? ?\fB\-\-\fR? \fIfileName packageName\fR
.br
-\fBload \fIfileName packageName interp\fR
+\fBload\fR ?\fB\-global\fR? ?\fB\-lazy\fR? ?\fB\-\-\fR? \fIfileName packageName interp\fR
.BE
-
.SH DESCRIPTION
.PP
This command loads binary code from a file into the
@@ -56,9 +55,12 @@ by the package that is safe for use by untrusted code. For more information
on Safe\-Tcl, see the \fBsafe\fR manual entry.
.PP
The initialization procedure must match the following prototype:
+.PP
.CS
-typedef int Tcl_PackageInitProc(Tcl_Interp *\fIinterp\fR);
+typedef int \fBTcl_PackageInitProc\fR(
+ Tcl_Interp *\fIinterp\fR);
.CE
+.PP
The \fIinterp\fR argument identifies the interpreter in which the
package is to be loaded. The initialization procedure must return
\fBTCL_OK\fR or \fBTCL_ERROR\fR to indicate whether or not it completed
@@ -71,12 +73,10 @@ in an application. If a given \fIfileName\fR is loaded into multiple
interpreters, then the first \fBload\fR will load the code and
call the initialization procedure; subsequent \fBload\fRs will
call the initialization procedure without loading the code again.
-.VS 8.5
For Tcl versions lower than 8.5, it is not possible to unload or reload a
package. From version 8.5 however, the \fBunload\fR command allows the unloading
of libraries loaded with \fBload\fR, for libraries that are aware of the
Tcl's unloading mechanism.
-.VE 8.5
.PP
The \fBload\fR command also supports packages that are statically
linked with the application, if those packages have been registered
@@ -104,6 +104,22 @@ Otherwise, the \fBload\fR command searches for a dynamically loaded
package by that name, and uses it if it is found. If several
different files have been \fBload\fRed with different versions of
the package, Tcl picks the file that was loaded first.
+.PP
+If \fB\-global\fR is specified preceding the filename, all symbols
+found in the shared library are exported for global use by other
+libraries. The option \fB\-lazy\fR delays the actual loading of
+symbols until their first actual use. The options may be abbreviated.
+The option \fB\-\-\fR indicates the end of the options, and should
+be used if you wish to use a filename which starts with \fB\-\fR
+and you provide a packageName to the \fBload\fR command.
+.PP
+On platforms which do not support the \fB\-global\fR or \fB\-lazy\fR
+options, the options still exist but have no effect. Note that use
+of the \fB\-global\fR or \fB\-lazy\fR option may lead to crashes
+in your application later (in case of symbol conflicts resp. missing
+symbols), which cannot be detected during the \fBload\fR. So, only
+use this when you know what you are doing, you will not get a nice
+error message when something is wrong with the loaded library.
.SH "PORTABILITY ISSUES"
.TP
\fBWindows\fR\0\0\0\0\0
@@ -119,9 +135,12 @@ When loading a DLL in the current directory, Windows will ignore
.QW ./
as a path specifier and use a search heuristic to find the DLL instead.
To avoid this, load the DLL with:
+.RS
+.PP
.CS
\fBload\fR [file join [pwd] mylib.DLL]
.CE
+.RE
.SH BUGS
.PP
If the same file is \fBload\fRed by different \fIfileName\fRs, it will
@@ -129,6 +148,7 @@ be loaded into the process's address space multiple times. The
behavior of this varies from system to system (some systems may
detect the redundant loads, others may not).
.SH EXAMPLE
+.PP
The following is a minimal extension:
.PP
.CS
@@ -156,20 +176,21 @@ it can then be loaded into Tcl with the following:
.CS
# Load the extension
switch $tcl_platform(platform) {
- windows {
- \fBload\fR [file join [pwd] foo.dll]
- }
- unix {
- \fBload\fR [file join [pwd] libfoo[info sharedlibextension]]
- }
+ windows {
+ \fBload\fR [file join [pwd] foo.dll]
+ }
+ unix {
+ \fBload\fR [file join [pwd] libfoo[info sharedlibextension]]
+ }
}
# Now execute the command defined by the extension
foo
.CE
-
.SH "SEE ALSO"
-info sharedlibextension, Tcl_StaticPackage(3), safe(n)
-
+info sharedlibextension, package(n), Tcl_StaticPackage(3), safe(n)
.SH KEYWORDS
-binary code, loading, safe interpreter, shared library
+binary code, dynamic library, load, safe interpreter, shared library
+'\"Local Variables:
+'\"mode: nroff
+'\"End: