c++ - Error: cannot call constructor -
i have included new module ns2 evaluation of video transmission. have make changes required files agent.h ,agent.cc, makefile , on. during make getting stuck error. error is:
myevalvid/myudp.cc: in member function ‘virtual void myudpagent::sendmsg(int, appdata*, const char*)’: myevalvid/myudp.cc:56:123: warning: format ‘%d’ expects argument of type ‘int’, argument 4 has type ‘long unsigned int’ [-wformat] myevalvid/myudp.cc:78:123: warning: format ‘%d’ expects argument of type ‘int’, argument 4 has type ‘long unsigned int’ [-wformat] make: *** no rule make target `myevalvid/myevalvid_sink.o ', needed `ns'. stop.
the code is
#include "myudp.h" #include "rtp.h" #include "random.h" #include "address.h" #include "ip.h" static class myudpagentclass : public tclclass { public: myudpagentclass() : tclclass("agent/myudp") {} tclobject* create(int, const char*const*) { return (new myudpagent()); } } class_myudp_agent; myudpagent::myudpagent() : id_(0), openfile(0) { bind("packetsize_", &size_); } void myudpagent::sendmsg(int nbytes, appdata* data, const char* flags) { packet *p; int n; char buf[100]; //added smallko if (size_) n = nbytes / size_; else printf("error: myudp size = 0\n"); if (nbytes == -1) { printf("error: sendmsg() udp should not -1\n"); return; } // if sending data, must fit within single packet. if (data && nbytes > size_) { printf("error: data greater maximum myudp packet size\n"); return; } double local_time = scheduler::instance().clock(); while (n-- > 0) { p = allocpkt(); hdr_cmn::access(p)->size() = size_; hdr_rtp* rh = hdr_rtp::access(p); rh->flags() = 0; rh->seqno() = ++seqno_; hdr_cmn::access(p)->timestamp() = (u_int32_t)(samplerate*local_time); hdr_cmn::access(p)->sendtime_ = local_time; // (smallko) if(openfile!=0){ hdr_cmn::access(p)->frame_pkt_id_ = id_++; sprintf(buf, "%-16f id %-16d udp %-16d\n", local_time, hdr_cmn::access(p)->frame_pkt_id_, hdr_cmn::access(p)->size()-28); fwrite(buf, strlen(buf), 1, bwfile); //printf("%-16f id %-16d udp %-16d\n", local_time, hdr_cmn::access(p)->frame_pkt_id_, hdr_cmn::access(p)->size()-28); } // add "beginning of talkspurt" labels (tcl/ex/test-rcvr.tcl) if (flags && (0 ==strcmp(flags, "new_burst"))) rh->flags() |= rtp_m; p->setdata(data); target_->recv(p); } n = nbytes % size_; if (n > 0) { p = allocpkt(); hdr_cmn::access(p)->size() = n; hdr_rtp* rh = hdr_rtp::access(p); rh->flags() = 0; rh->seqno() = ++seqno_; hdr_cmn::access(p)->timestamp() = (u_int32_t)(samplerate*local_time); hdr_cmn::access(p)->sendtime_ = local_time; // (smallko) if(openfile!=0){ hdr_cmn::access(p)->frame_pkt_id_ = id_++; sprintf(buf, "%-16f id %-16d udp %-16d\n", local_time, hdr_cmn::access(p)->frame_pkt_id_, hdr_cmn::access(p)->size()-28); fwrite(buf, strlen(buf), 1, bwfile); //printf("%-16f id %-16d udp %-16d\n", local_time, hdr_cmn::access(p)->frame_pkt_id_, hdr_cmn::access(p)->size()-28); } // add "beginning of talkspurt" labels (tcl/ex/test-rcvr.tcl) if (flags && (0 == strcmp(flags, "new_burst"))) rh->flags() |= rtp_m; p->setdata(data); target_->recv(p); } idle(); } int myudpagent::command(int argc, const char*const* argv) { if(argc ==2) { //added smallko if (strcmp(argv[1], "closefile") == 0) { if(openfile==1) fclose(bwfile); return (tcl_ok); } } if (argc ==3) { //added smallko if (strcmp(argv[1], "set_filename") == 0) { strcpy(bwfile, argv[2]); bwfile = fopen(bwfile, "w"); openfile=1; return (tcl_ok); } } return (udpagent::command(argc, argv)); }
please me sort out error.
as error says, can't call constructor directly, line seems trying do:
udpagent::udpagent();
you want remove line. constructor being called (implicitly) @ beginning of constructor. put udpagent()
@ start of initialiser list, if want explicit it.
Comments
Post a Comment