[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Linkage betwen Otcl and C++ code: problem not resolved (be patient please)
> From: Luca Liberti <[email protected]>
> Date: Thu, 08 Jul 1999 10:45:32 +0200
> Hello everybody,
> I'm using ns 2.1b5.
> Someone knows because NS doesn't want to execute the linkage between the C++
> code and Tcl code.
> Look please this simple example and tell me what I miss.
>
> ~~~~
> The error mesage is:
>
> (_o11 cmd line 1)
> invoked from within
> "_o11 cmd hello"
> invoked from within
> "catch "$self cmd $args" ret"
> (procedure "_o11" line 2)
> (SplitObject unknown line 2)
> invoked from within
> "$p hello"
> (file "prova_otcl_linkage.tcl" line 4)
>
> ~~~~
> This is the Otcl script
>
> # file "prova_otcl_linkage.tcl"
> Class Agent/Prova -superclass Agent
> set ns [new Simulator]
> set p [new Agent/Prova]
> $p hello
> exit 1
>
> ~~~~
> This is the simple C++ code
>
> // file "prova_otcl_linkage.cc"
> #include "agent.h"
> #include <stdio.h>
> #include "packet.h"
> #include "tclcl.h"
> #include "address.h"
> #include "ip.h"
>
> //-------- class definition -------------------------
> class prova : public Agent {
> public:
> prova();
> int command(int argc, const char*const* argv);
> };
>
> //-------- Otcl linkage -------------------------
> static class provaClass : public TclClass {
> public:
> provaClass() : TclClass("Agent/Prova") {}
> TclObject* create(int, const char*const*) {
> return (new prova());
In gdb, why don't you put a stop here and see what's going on?
Kannan
> }
> } class_prova;
> //---------------------------------
>
>
> prova::prova() : Agent(PT_NTYPE)
> {
> printf("@@@@@@@ I am here");
> }
>
> int prova::command(int argc, const char*const* argv)
> {
> Tcl& tcl = Tcl::instance();
> if (argc == 2) {
> if (strcmp(argv[1], "hello") == 0) {
> printf("C++ prova : hello I am here");
> tcl.evalc("puts Otcl Agent/Prova: Hello I am here");
> return (TCL_OK);
> }
> }
> return (Agent::command(argc, argv));
> }
> //------------------------------------
>
> Thanks in advance to all NS comunitty.
> Luca Liberti
>