## Tcl9.0.3/Tk9.0.3 Documentation > Tcl C API > InitStubs

### Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

  NAME
    Tcl_InitStubs — Tcl 残余 の仕組みを初期化する initialize the Tcl stubs mechanism
  SYNOPSIS
    #include <tcl.h>
    const char *
    Tcl_InitStubs(interp, version, exact)
  引数 ARGUMENTS
    Tcl_Interp *interp (入力in)
    const char *version (in)
    int exact (入力in)
  緒論 INTRODUCTION
  説明 DESCRIPTION
  SEE ALSO
  KEYWORDS

### NAME

Tcl_InitStubs — Tcl 残余 の仕組みを初期化する initialize the Tcl stubs mechanism

### SYNOPSIS

#include <tcl.h>
const char *
Tcl_InitStubs(interp, version, exact)

### 引数 ARGUMENTS

Tcl_Interp *interp (入力in)
  Tcl 解釈実行機能操作子｡　　 Tcl interpreter handle.

const char *version (in)
  Tclが受容れられる最小版番号｡通常は単に"9.0"｡もし､8.6 と 9.0の両方が受容れられれば､"8.6-"｡ A version string, indicating which minimal version of Tcl is accepted. Normally just "9.0". Or "8.6-" if both 8.6 and 9.0 are accepted.

int exact (入力in)
  1 の意味は version によって指定される特定の版のみが受容れられる｡ 0 の意味は version より新しい版も受容れる｡もしversion末尾に-が伴うと､更に上の主の版も同じく受容れられる､伴わない場合は､主版番号は versionと同じでなければならない｡他のビットは意味がない｡ 1 means that only the particular version specified by version is accepted. 0 means that versions newer than version are also accepted. If theversion ends with -, higher major versions are accepted as well, otherwise the major version must be the same as in version. Other bits have no effect.

### 緒論 INTRODUCTION

Tcl stubs 仕組みは実行時に動的に特定の Tcl 実装に拡張を束縛する方法で定義される｡これは二つの利点を Tcl 使用者に提供する: The Tcl stubs mechanism defines a way to dynamically bind extensions to a particular Tcl implementation at run time. This provides two significant benefits to Tcl users:

1. stubs 仕組みを使う拡張機能は､Tcl主版番号が同じである限り､再機械語翻訳や連結なしに多くの版の Tcl に積込む事ができる｡ Extensions that use the stubs mechanism can be loaded into multiple versions of Tcl without being recompiled or relinked, as long as the major Tcl version is the same.

2. stubs 仕組みを使う拡張機能は静的に連結された Tcl 応用譜に動的に積込む事ができる｡ Extensions that use the stubs mechanism can be dynamically loaded into statically-linked Tcl applications.

stubs 仕組みは､ Tcl API への相互作用を定義する函数表を移送することで完遂する｡拡張機能は Tcl API を通して函数表を利用できるので､どの Tcl 外部函数の記号への直接の参照はない｡この再方向変更は拡張に透明であり､拡張の著者は全ての公開された Tcl 函数を継続して使用できる｡ The stubs mechanism accomplishes this by exporting function tables that define an interface to the Tcl API. The extension then accesses the Tcl API through offsets into the function table, so there are no direct references to any of the Tcl library's symbols. This redirection is transparent to the extension, so an extension writer can continue to use all public Tcl functions as documented.

stubs 仕組みは､ Tcl 解釈実行機能に協調した応用譜に変更を要求しない｡唯､ C-に基く Tcl 拡張の開発者はその拡張に伴う stubs 仕組みを使う為の手続を踏む必要がある｡ The stubs mechanism requires no changes to applications incorporating Tcl interpreters. Only developers creating C-based Tcl extensions need to take steps to use the stubs mechanism with their extensions.

stubs 仕組みを有効にする為に拡張は次の手順を踏む必要がある: Enabling the stubs mechanism for an extension requires the following steps:

1. 他のどの Tcl 函数の呼出しよりも前に拡張内の Tcl_InitStubs を呼ぶ｡ Call Tcl_InitStubs in the extension before calling any other Tcl functions.

2. USE_TCL_STUBS 記号を定義する｡典型的には､拡張を機械語翻訳する時に -DUSE_TCL_STUBS 旗印を含めるのがよい｡ Define the USE_TCL_STUBS symbol. Typically, you would include the -DUSE_TCL_STUBS flag when compiling the extension.

3. 標準 Tcl 外部函数の代りに拡張 Tcl stubs 外部函数に連結する｡ 譬えば､ Tcl 9.0 ABI を使う為に､Unix では､外部函数の名前は libtclstub.a ; 　Windows では外部函数の名前は tclstub.lib である｡ Link the extension with the Tcl stubs library instead of the standard Tcl library. For example, to use the Tcl 9.0 ABI on Unix platforms, the library name is libtclstub.a; on Windows platforms, the library name is tclstub.lib.

もし拡張が Tk API をも必要とする場合､ Tk stubs 対話機能を初期化する為に Tk_InitStubs も呼出し､ Tk_InitStubs 外部函数に連結する必要がある｡更なる情報については Tk_InitStubs の頁を参照されたい｡ If the extension also requires the Tk API, it must also call Tk_InitStubs to initialize the Tk stubs interface and link with the Tk stubs libraries. See the Tk_InitStubs page for more information.

### 説明 DESCRIPTION

Tcl_InitStubs は stub 表ポインターの初期化を試み､正しい版の Tcl が積込まれる事を確実にする｡更に､処理子を解釈する為に､引数として､版番号と､拡張が厳密な版の合致を要求しているか否かを指し示す論理値とを受入れる｡exactが0の場合､versionより新しい版番号も受容れられる｡もしversion末尾に-を伴うと､上の主版番号も同じく受容れられる､伴わない場合､主版番号は同じくversion以内でなければならない｡1 の場合､指定されたversionのみが受容れられる｡versionはpackage requireに記述されたどの様な構造でもよい(取扱い説明書のREQUIREMENTのPACKAGE節参照)｡package requireに伴う多重要求は受容れられない｡ Tcl_InitStubs は要求を満足する Tcl の実際の版番号を含む文字列を返す､亦はもし Tcl 版番号が受入れられないか､ stubs を運営していないか､他の不都合条件が生じた場合は NULL を返す｡ Tcl_InitStubs attempts to initialize the stub table pointers and ensure that the correct version of Tcl is loaded. In addition to an interpreter handle, it accepts as arguments a version number and a Boolean flag indicating whether the extension requires an exact version match or not. If exact is 0, then versions newer than version are also accepted. If theversion ends with -, higher major versions are accepted as well, otherwise the major version must be the same as in version. 1 means that only the specified version is accepted. version can be any construct as described for package require (PACKAGE manual page in the section REQUIREMENT). Multiple requirement strings like with package require are not supported. Tcl_InitStubs returns a string containing the actual version of Tcl satisfying the request, or NULL if the Tcl version is not accepted, does not support stubs, or any other error condition occurred.

### SEE ALSO

Tk_InitStubs package

### KEYWORDS

stubs
Copyright © 1998-1999 Scriptics Corporation