0
votes

I'm receiving error "Overriding error" even though all libraries avilable at the workspace. Below are the relevant code snippets with mentioned errors:

#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;
};

Error: ‘virtual void inet::InetPacketBytesPrinter::printMessage(std::ostream&, omnetpp::cMessage*) const’ marked ‘override’, but does not override

Register_MessagePrinter(InetPacketBytesPrinter);

Error: invalid new-expression of abstract class type ‘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
}

Console: 12:46:31 **** Incremental Build of configuration gcc-release for project ansainet **** make MODE=release all cd src && make all make[1]: Entering directory '/home/abbuser/Subhash/omnetpp-5.6.1/samples/ansainet/src' inet/common/packet/InetPacketBytesPrinter.cc inet/common/packet/InetPacketBytesPrinter.cc:33:18: error: ‘virtual void inet::InetPacketBytesPrinter::printMessage(std::ostream&, omnetpp::cMessage*) const’ marked ‘override’, but does not override virtual void printMessage(std::ostream& os, cMessage msg) const override; ^~~~~~~~~~~~ In file included from /home/abbuser/Subhash/omnetpp-5.6.1/include/omnetpp/globals.h:21:0, from /home/abbuser/Subhash/omnetpp-5.6.1/include/omnetpp/cobjectfactory.h:20, from /home/abbuser/Subhash/omnetpp-5.6.1/include/omnetpp.h:30, from ./inet/common/INETDefs.h:28, from inet/common/packet/InetPacketBytesPrinter.cc:18: inet/common/packet/InetPacketBytesPrinter.cc: In function ‘void inet::{anonymous}::__onstartup_func_36()’: inet/common/packet/InetPacketBytesPrinter.cc:36:1: error: invalid new-expression of abstract class type ‘inet::InetPacketBytesPrinter’ Register_MessagePrinter(InetPacketBytesPrinter); ^ inet/common/packet/InetPacketBytesPrinter.cc:24:16: note: because the following virtual functions are pure within ‘inet::InetPacketBytesPrinter’: class INET_API InetPacketBytesPrinter : public cMessagePrinter ^~~~~~~~~~~~~~~~~~~~~~ In file included from /home/abbuser/Subhash/omnetpp-5.6.1/include/omnetpp.h:68:0, from ./inet/common/INETDefs.h:28, from inet/common/packet/InetPacketBytesPrinter.cc:18: /home/abbuser/Subhash/omnetpp-5.6.1/include/omnetpp/cmessageprinter.h:110:22: note: virtual void omnetpp::cMessagePrinter::printMessage(std::ostream&, omnetpp::cMessage, const omnetpp::cMessagePrinter::Options*) const virtual void printMessage(std::ostream& os, cMessage *msg, const Options *options) const = 0; ^~~~~~~~~~~~ Makefile:1127: recipe for target '../out/gcc-release/src/inet/common/packet/InetPacketBytesPrinter.o' failed make[1]: Leaving directory '/home/abbuser/Subhash/omnetpp-5.6.1/samples/ansainet/src' make[1]: *** [../out/gcc-release/src/inet/common/packet/InetPacketBytesPrinter.o] Error 1 make: *** [all] Error 2 Makefile:4: recipe for target 'all' failed "make MODE=release all" terminated with exit code 2. Build might be incomplete.

12:46:35 Build Failed. 6 errors, 0 warnings. (took 3s.328ms)

2

2 Answers

1
votes

The INET version you are trying to build is too old to be built with OMNeT++ 5.6. You should either use an older OMNeT++ version (that is indicated in the README file of the INET release), or use a newer version INET (probably the latest 3.6.x version?)

0
votes

According to this documentation the cMessagePrinter::printMessage method takes three parameters, but your version only has two, therefore it's not an override.

Change your printMessage signature to be the same as the method you are overriding.