Tcl_StaticLibrary(3)
π Tcl_StaticLibrary β bestie edition π
okay so this is a page from the Tcl Library Procedures manual (that's the manual name, mwah, love that for us) and it's all about Tcl_StaticLibrary and Tcl_StaticPackage π
β¨ NAME β¨
Tcl_StaticLibrary, Tcl_StaticPackage β the way these two make a statically linked library available via the load command π
πΈ SYNOPSIS πΈ
#include <tcl.h>
Tcl_StaticLibrary(interp, prefix, initProc, safeInitProc)
Tcl_StaticPackage(interp, prefix, initProc, safeInitProc)
π¦ ARGUMENTS π¦
Tcl_Interp *interp(in) β if it's notNULL, it points at an interpreter that the library has already been incorporated into (like, the caller already ran the right initialization procedure, no notes π ).NULLmeans the library hasn't been incorporated into any interpreter yet.const char *prefix(in) β the prefix for the library's initialization function. Normally it's in titlecase (first letter uppercase, all the others lowercase), but bestie, that's no longer required β¨Tcl_LibraryInitProc *initProc(in) β the procedure you invoke to incorporate this library into a trusted interpreter π«ΆTcl_LibraryInitProc *safeInitProc(in) β the procedure you call to incorporate this library into a safe interpreter (aka one that's gonna execute untrusted scripts π).NULLmeans the library cannot be used in safe interpreters. periodt.
π DESCRIPTION π
So you invoke this procedure to announce that a library has been linked statically with a Tcl application, and optionally that it's already been incorporated into an interpreter. Once Tcl_StaticLibrary has been invoked for a library, that library can then be incorporated into interpreters using the load command. π
Tcl_StaticLibrary is normally invoked only by the Tcl_AppInit procedure for the application β not by libraries for themselves. Like, Tcl_StaticLibrary should only be invoked for statically linked libraries, and code in the library itself should not need to know whether the library is dynamically loaded or statically linked. iykyk π
When the load command is used later to incorporate the library into an interpreter, one of initProc and safeInitProc will be invoked, depending on whether the target interpreter is safe or not. And initProc and safeInitProc must both match this prototype, no exceptions:
typedef int Tcl_LibraryInitProc(
Tcl_Interp *interp);
The interp argument identifies the interpreter in which the library is to be incorporated. The initialization procedure must return TCL_OK or TCL_ERROR to indicate whether or not it completed successfully; if there's an error it should set the interpreter's result to point to an error message. The result or error from the initialization procedure will be returned as the result of the load command that caused the initialization procedure to be invoked. slay β¨
ngl,Tcl_StaticLibrarywas namedTcl_StaticPackageback in Tcl 8.6 and earlier β but the old name is deprecated now, so don't come for me, use the new one π
π¨ ALSO IMPORTANT: Tcl_StaticLibrary can not be used in stub-enabled extensions. fr fr, not a vibe.
π₯ KEYWORDS π₯
initialization procedure, package, static linking
π SEE ALSO π
and that's the whole page bestie π«Ά this one came from Tcl version 7.5 (yes the footer said Tcl 7.5 Tcl_StaticLibrary(3)) β go forth and statically link responsibly πβ¨ππ¦πΈπ
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- Copyright (c) 1995-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms