最近移植柯老师的示例代码measure/mudp 相关的代码,发现了问题,但是网上也没找到解决方法,很多人有相同问题但是没有最后解决。
1、在Makefile中不加 -fpermissive, 会报错误,说mUdpAgent 不能直接调用UdpAgent(),
在makefile中加入
CCOPT = -Wall -Wno-write-strings -fpermissive编译能通过,但是运行的时候会出现
invalid command name "Agent/TCPSink/mTCPSink" while executing "Agent/TCPSink/mTCPSink creat -o83"
因此也是不能通过的。
2、具体解决方案:
在源代码中
mUdpAgent::mUdpAgent() : id_(0), openfile(0) { bind("packetSize_", &size_); UdpAgent::UdpAgent(); }UdpAgent::UdpAgent()调用是有问题的,改为:
mUdpAgent::mUdpAgent() :UdpAgent(), id_(0), openfile(0) { bind("packetSize_", &size_); }重新编译后,运行通过,不会出现1中的问题。