1Tcl_InitStubs(3)            Tcl Library Procedures            Tcl_InitStubs(3)
2
3
4
5______________________________________________________________________________
6

NAME

8       Tcl_InitStubs - initialize the Tcl stubs mechanism
9

SYNOPSIS

11       #include <tcl.h>
12
13       const char *
14       Tcl_InitStubs(interp, version, exact)
15

ARGUMENTS

17       Tcl_Interp *interp (in)          Tcl interpreter handle.
18
19       const char *version (in)         A  version string consisting of one or
20                                        more  decimal  numbers  separated   by
21                                        dots.
22
23       int exact (in)                   Non-zero  means that only the particu‐
24                                        lar version specified  by  version  is
25                                        acceptable.   Zero means that versions
26                                        newer than version are also acceptable
27                                        as  long  as  they have the same major
28                                        version number as version.
29_________________________________________________________________
30

INTRODUCTION

32       The Tcl stubs mechanism defines a way to dynamically bind extensions to
33       a particular Tcl implementation at run time.  This provides two signif‐
34       icant benefits to Tcl users:
35
36       1)   Extensions that use the stubs mechanism can be loaded into  multi‐
37            ple versions of Tcl without being recompiled or relinked.
38
39       2)   Extensions  that use the stubs mechanism can be dynamically loaded
40            into statically-linked Tcl applications.
41
42       The stubs mechanism accomplishes this by exporting function tables that
43       define  an  interface  to the Tcl API.  The extension then accesses the
44       Tcl API through offsets into the function table, so there are no direct
45       references  to  any  of the Tcl library's symbols.  This redirection is
46       transparent to the extension, so an extension writer  can  continue  to
47       use all public Tcl functions as documented.
48
49       The  stubs  mechanism requires no changes to applications incorporating
50       Tcl interpreters.  Only developers creating C-based Tcl extensions need
51       to take steps to use the stubs mechanism with their extensions.
52
53       Enabling  the  stubs  mechanism for an extension requires the following
54       steps:
55
56       1)   Call Tcl_InitStubs in the extension before calling any  other  Tcl
57            functions.
58
59       2)   Define the USE_TCL_STUBS symbol.  Typically, you would include the
60            -DUSE_TCL_STUBS flag when compiling the extension.
61
62       3)   Link the extension with the Tcl stubs library instead of the stan‐
63            dard  Tcl  library.   On Unix platforms, the library name is libt‐
64            clstub8.1.a;  on  Windows   platforms,   the   library   name   is
65            tclstub81.lib.
66
67       If  the  extension also requires the Tk API, it must also call Tk_Init‐
68       Stubs to initialize the Tk stubs interface and link with the  Tk  stubs
69       libraries.  See the Tk_InitStubs page for more information.
70

DESCRIPTION

72       Tcl_InitStubs attempts to initialize the stub table pointers and ensure
73       that the correct version of Tcl is loaded.  In addition  to  an  inter‐
74       preter  handle,  it accepts as arguments a version number and a Boolean
75       flag indicating whether the extension requires an exact  version  match
76       or  not.   If  exact  is 0, then the extension is indicating that newer
77       versions of Tcl are acceptable as long as they have the same major ver‐
78       sion  number as version; non-zero means that only the specified version
79       is acceptable.  Tcl_InitStubs returns a string  containing  the  actual
80       version  of  Tcl  satisfying the request, or NULL if the Tcl version is
81       not acceptable, does not support stubs, or any  other  error  condition
82       occurred.
83

SEE ALSO

85       Tk_InitStubs
86

KEYWORDS

88       stubs
89
90
91
92Tcl                                   8.1                     Tcl_InitStubs(3)
Impressum