check_and_cast<cPacket>(msg)->hasBitError
You should read in the manual the difference between cPacket and cMessage
--
You received this message because you are subscribed to the Google Groups "omnetpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
It is a problem how the message has created, if the message was created like cPacket you can convert, but if the message was originally created like cMessage, you will never convert to cPacket and if you force the conversion with static_cast, the code will access to incorrect areas because cMessage doesn’t have error data.
It is a basic c++ inherence rule.
Check_and_cast does a dynamic_cast, like the result of the conversion is null it throws an error
An alternative is
cPacket pkt = dynamic_cast<cPacket*>(msg);
if (pk)
{
// it is a packet
If (pk->hasBitError())
…..
}
else
{
// it isn’t a packet, is it a timer?
….