Having C++ Program Call Functions Defined for TCL 
Author Message
 Having C++ Program Call Functions Defined for TCL

Hello, everyone,

I've inherited some complex code that was written to be called in a TCL
interpreter.  It was defined in a function that is then appropriately
exported to TCL visibility and is called in a script executed in a TCL
interpreter.  The program that uses this function works correctly.  A test
harness that I'm now writing does not.  The TCL interpreter is saying that
the function isn't found.

However, when I view the contents of the binary test harness using 'nm', I
see that the necessary functions are defined:

prompt> nm -a faultlist-test-s27-io| c++filt |grep tclFunction
08365bd0 W TclCommand<tclFunction_t>::~TclCommand(void)
08365ce0 W TclCommand<tclFunction_t>::TclCommand(TclInterpreter &, char
const *)
08365e04 W TclStaticCommand<tclfunction_t>::TclStaticCommand(char const *)
08365d40 W TclCommand<tclFunction_t>::create(TclInterpreter &, char const *)
08365c30 W TclCommand<tclFunction_t>::destroy(void *)
08365c70 W TclCommand<tclFunction_t>::invoke(void *, Tcl_Interp *, int, char
**)
0820b8c0 T TclCommand<tclFunction_t>::invoke(int, char **)
08662878 B tclFunction_registrar
08365de0 W TclCommand<tclFunction_t>::register_as(char const *)

But, observe the error message that the following code when it is called
inside my C++ test harness:

    ...
    string command ("tclFunction ");
    command += argument;

    if (tclInterpreter.eval(command.c_str()) == TCL_ERROR)
    {
        string msg = "tclFunction error: ";
        msg += tclInterpreter.result();
        throw TclFunctionFailure (msg.c_str());
    }
    ...

The error message in the thrown exception:

    tclFunction error: invalid command name: tclFunction

Can anyone tell me what else I need to do to expose functions that were
written in C/C++ to a TCL interpreter that I'm creating in my C++ program?
There is obviously something that the original program is doing that my test
harness is not.

Thanks!
Scott

--
Remove ".nospam" from the user ID in my e-mail to reply via e-mail.



Sat, 15 Oct 2005 02:07:59 GMT  
 Having C++ Program Call Functions Defined for TCL
To anyone that was so kind as to read the original post: please don't bother
responding.  I was able to isolate some environment-specific issues for this
program that allowed me to resolve this problem.

Thanks,
Scott



Quote:
> Hello, everyone,

> I've inherited some complex code that was written to be called in a TCL
> interpreter.  It was defined in a function that is then appropriately
> exported to TCL visibility and is called in a script executed in a TCL
> interpreter.  The program that uses this function works correctly.  A test
> harness that I'm now writing does not.  The TCL interpreter is saying that
> the function isn't found.

> However, when I view the contents of the binary test harness using 'nm', I
> see that the necessary functions are defined:

> prompt> nm -a faultlist-test-s27-io| c++filt |grep tclFunction
> 08365bd0 W TclCommand<tclFunction_t>::~TclCommand(void)
> 08365ce0 W TclCommand<tclFunction_t>::TclCommand(TclInterpreter &, char
> const *)
> 08365e04 W TclStaticCommand<tclfunction_t>::TclStaticCommand(char const *)
> 08365d40 W TclCommand<tclFunction_t>::create(TclInterpreter &, char const
*)
> 08365c30 W TclCommand<tclFunction_t>::destroy(void *)
> 08365c70 W TclCommand<tclFunction_t>::invoke(void *, Tcl_Interp *, int,
char
> **)
> 0820b8c0 T TclCommand<tclFunction_t>::invoke(int, char **)
> 08662878 B tclFunction_registrar
> 08365de0 W TclCommand<tclFunction_t>::register_as(char const *)

> But, observe the error message that the following code when it is called
> inside my C++ test harness:

>     ...
>     string command ("tclFunction ");
>     command += argument;

>     if (tclInterpreter.eval(command.c_str()) == TCL_ERROR)
>     {
>         string msg = "tclFunction error: ";
>         msg += tclInterpreter.result();
>         throw TclFunctionFailure (msg.c_str());
>     }
>     ...

> The error message in the thrown exception:

>     tclFunction error: invalid command name: tclFunction

> Can anyone tell me what else I need to do to expose functions that were
> written in C/C++ to a TCL interpreter that I'm creating in my C++ program?
> There is obviously something that the original program is doing that my
test
> harness is not.

> Thanks!
> Scott

> --
> Remove ".nospam" from the user ID in my e-mail to reply via e-mail.



Sat, 15 Oct 2005 03:35:07 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VC++ calling fortran function and fortran function calling a c++ function

2. Calling functions defined in modules in Python from C++

3. Calling C++ function from TCL

4. Calling C++ functions from tcl/tk and vice versa

5. I need to call some user init_proc before calling any Tcl or User Defined proc

6. C functions calling {C++/Ada/...} functions

7. C++ program calling tcl scripts for UI

8. Call a defined dll-function with various kinds of data-types

9. Defining and calling functions in Python

10. c++ calling fortran and fortran calling C++

11. C++ calling Fortran calling C++

12. calling Visual C++ or Prolog calling Visual C++

 

 
Powered by phpBB® Forum Software