Re: Using Tcl_*ObjCmd in extensions
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Using Tcl_*ObjCmd in extensions

From: Helmut Giese <hgiese@ratiosoft.com>
Date: Tue Dec 20 2005 - 19:31:40 CET

Hi Eric,
>On few occasions when writing a C based extension to Tcl, I want to call
>Tcl command procedures (i.e. the set of Tcl_*ObjCmd functions).
>
>After linking against the stubs library, symbols referring to these
>functions remain unresolved.
Uh? Your linker complains about 'unresolved externals'? I don't think
this ever happened to me. Show your setup, and I'm sure people will
help you straighten things out.

>This does not "feel good". However, when dynamically loading the shared
>library, there is no complaint (which I does surprise me), and the
>library's functionality works fine.
>
>Still, I'm unsure whether this is evil.
Quite the contrary: It's a blessing. (hm, Xmas time showing thru ? :)
)

> Could anybody expand a bit why
>it is(n't)?
Well, you have what is called a 'stubs table' - an array of pointers
to the 'real' functions, which get filled in during intialisiation of
the stubs mechanism.
When you call a function Tcl_Foo (and have USE_TCL_STUBS #defined)
this call is converted (via a macro) to calling the function pointer
at, say, slot 37, which points to the 'real' Tcl_Foo. Tcl_Bar is
converted to use slot (stub) 38, etc.
All this is standard C - cleverly thought out, but still nothing
magic. Have a look at how the stub table is initialised, and - once
you grok the mechanism - you'll wonder why you didn't think of it
yourself. :)
HTH
Helmut Giese
Received on Fri Dec 23 19:02:34 2005