Re: Problem with Tcl_SetResult and Tclkit under Windows

Gerard Durand <[email protected]> Tue, 12 Apr 2011 17:22:13 +0000 (UTC)
Newsgroups gmane.comp.lang.tcl.starkit
Message-ID <[email protected]>
Pat Thoyts <patthoyts <at> gmail.com> writes:

> 
> On 12 April 2011 15:18, Gerard Durand <gerard-florence.durand <at> orange.fr>
wrote:
> > Hi,
> > I'm trying to return a long chain from C to Tcl.
> > If I use :
> > sprintf(interp->result,"%s",Message) ; with Message containing my character
> 
> Don't do that. Its been deprecated for about 12 years or more.
> 

OK, but I have still many codes doing that ...


> 
> Tcl_SetObjResult(interp, Tcl_NewStringObj(Message, -1));
> should be the way to do this. This should take a copy of the string
> and allocate it into a new Tcl object. I'd suspect the other failures
> are due to memory for the string being allocated by one heap while the
> Tcl copy used another heap.
> 
> Make sure that your extension DLL is compiled with TCL_STUBS and
> linked to tclstub8[456].lib. Tclkit cannot work with non-stubs linked
> extensions.
> 

That was the reason apparently. Now I have compiled and linked with TCL and TK
stubs and it works on a small test. Normally, it should also work on a bigger
code (I hope :-))

Thanks for the help.

Gerard



-- 
You received this message because you are subscribed to the "starkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/starkit?hl=en