微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

OMNET ++中的iNET框架中的覆盖错误

如何解决OMNET ++中的iNET框架中的覆盖错误

我收到错误“覆盖错误”,即使所有库在工作区都可用。以下是带有提到的错误的相关代码段:

#include "inet/common/INETDefs.h"
namespace inet {
#if OMNETPP_VERSION >= 0x0405
class INET_API InetPacketBytesPrinter : public cmessagePrinter
{
protected:
mutable bool showEncapsulatedPackets;  
public:
InetPacketBytesPrinter() { showEncapsulatedPackets = true; }
virtual ~InetPacketBytesPrinter() {}
virtual int getscoreFor(cmessage *msg) const override;
virtual void printMessage(std::ostream& os,cmessage *msg) const override;
};

错误“虚拟无效inet :: InetPacketBytesPrinter :: printMessage(std :: ostream&,omnetpp :: cmessage *)const”标记为“覆盖”,但没有覆盖

Register_MessagePrinter(InetPacketBytesPrinter);

错误:抽象类类型“ inet :: InetPacketBytesPrinter”的新表达式无效

static const char INFO_SEPAR[] = "  \t";
int InetPacketBytesPrinter::getscoreFor(cmessage *msg) const{
return msg->isPacket() ? 18 : 0;
}
void InetPacketBytesPrinter::printMessage(std::ostream& os,cmessage *msg) const
{
std::string outs;
showEncapsulatedPackets = true;
for (cPacket *pk = dynamic_cast<cPacket *>(msg); showEncapsulatedPackets && pk; pk = pk->getEncapsulatedPacket()) {    
    std::ostringstream out;
    out << pk->getClassName() << ":" << pk->getByteLength() << " bytes";
    if (outs.length())
        out << INFO_SEPAR << outs;
    outs = out.str();
}
os << outs;
}
#endif
}

控制台: 12:46:31 ****用于项目ansainet的配置gcc-release的增量构建**** 使MODE =全部释放 cd src &&全部制作 make [1]:进入目录'/home/abbuser/Subhash/omnetpp-5.6.1/samples/ansainet/src' inet / common / packet / InetPacketBytesPrinter.cc inet / common / packet / InetPacketBytesPrinter.cc:33:18:错误:“虚拟无效inet :: InetPacketBytesPrinter :: printMessage(std :: ostream&,omnetpp :: cmessage *)const”标记为“覆盖”,但不会覆盖 虚拟void printMessage(std :: ostream&os,cmessage msg)const覆盖; ^ ~~~~~~~~~~~~ 在/home/abbuser/Subhash/omnetpp-5.6.1/include/omnetpp/globals.h:21:0包含的文件中, 来自/home/abbuser/Subhash/omnetpp-5.6.1/include/omnetpp/cobjectfactory.h:20, 来自/home/abbuser/Subhash/omnetpp-5.6.1/include/omnetpp.h:30, 来自./inet/common/INETDefs.h:28, 来自inet / common / packet / InetPacketBytesPrinter.cc:18: inet / common / packet / InetPacketBytesPrinter.cc:在函数“ void inet :: {anonymous} :: __ onstartup_func_36()”中: inet / common / packet / InetPacketBytesPrinter.cc:36:1:错误:抽象类类型“ inet :: InetPacketBytesPrinter”的新表达式无效 Register_MessagePrinter(InetPacketBytesPrinter); ^ inet / common / packet / InetPacketBytesPrinter.cc:24:16:注意:因为以下虚拟函数在“ inet :: InetPacketBytesPrinter”中是纯净的: INET_API InetPacketBytesPrinter类:公共cmessagePrinter ^ ~~~~~~~~~~~~~~~~~~~~~ 在/home/abbuser/Subhash/omnetpp-5.6.1/include/omnetpp.h:68:0包含的文件中, 来自./inet/common/INETDefs.h:28, 来自inet / common / packet / InetPacketBytesPrinter.cc:18: /home/abbuser/Subhash/omnetpp-5.6.1/include/omnetpp/cmessageprinter.h:110:22:注意:虚拟无效omnetpp :: cmessagePrinter :: printMessage(std :: ostream&,omnetpp :: cmessage ,const omnetpp :: cmessagePrinter :: Options *)const 虚拟无效printMessage(std :: ostream&os,cmessage * msg,const Options * options)const = 0; ^ ~~~~~~~~~~~~ Makefile:1127:目标'../out/gcc-release/src/inet/common/packet/InetPacketBytesPrinter.o'的配方失败 make [1]:离开目录'/home/abbuser/Subhash/omnetpp-5.6.1/samples/ansainet/src' make [1]:*** [../out/gcc-release/src/inet/common/packet/InetPacketBytesPrinter.o]错误1 使:*** [全部]错误2 Makefile:4:目标“全部”的配方失败 “ make MODE = release all”以退出代码2终止。构建可能不完整。

12:46:35生成失败。 6个错误,0个警告。 (耗时3s.328ms)

解决方法

您要构建的INET版本太旧,无法使用OMNeT ++ 5.6构建。您应该使用较旧的OMNeT ++版本(在INET发行版的README文件中指出),或使用较新的版本的INET(可能是最新的3.6.x版本?)

,

根据此documentationcMessagePrinter::printMessage方法使用三个参数,但是您的版本只有两个,因此它不是替代。

将您的printMessage签名更改为与您要覆盖的方法相同。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。