无法在 omnet++ 5.6.1 中关闭新消息到达门的索引

cannot gate index of arrival gate of new message in omnet++ 5.6.1

我正在学习 tictoc 教程,我想更改 tictoc12 的代码,以便我将获得我们收到消息的门的索引,这样消息就不会从同一个门发出。这是我的 handleMesssage() 函数:

void Txc12::handleMessage(cMessage *msg)
{
if (getIndex() == 3) {
    // Message arrived.
    EV << "Message " << msg << " arrived.\n";
    delete msg;
}
else {
    int arrivalGate = msg->getArrivalGate()->getIndex();
    EV << "arrival gate: " << arrivalGate << "\n";
    // We need to forward the message.
    forwardMessage(msg);
}
}

这是我收到的错误:

Simulation terminated with exit code: -1073741819 Working directory: D:/omnetpp-5.6.1/samples/tictoc Command line: tictoc.exe -m -u Qtenv omnetpp.ini

Environment variables: PATH=;D:\omnetpp-5.6.1\bin;D:\omnetpp-5.6.1\tools\win64\mingw64\bin;D:\omnetpp-5.6.1\tools\win64\usr\bin;;D:/omnetpp-5.6.1/ide/jre/bin/server;D:/omnetpp-5.6.1/ide/jre/bin;D:/omnetpp-5.6.1/ide/jre/lib/amd64;.;D:\omnetpp-5.6.1\bin;D:\omnetpp-5.6.1\tools\win64\mingw64\bin;D:\omnetpp-5.6.1\tools\win64\usr\local\bin;D:\omnetpp-5.6.1\tools\win64\usr\bin;D:\omnetpp-5.6.1\tools\win64\usr\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;D:\omnetpp-5.6.1\tools\win64\usr\bin\site_perl;D:\omnetpp-5.6.1\tools\win64\usr\bin\vendor_perl;D:\omnetpp-5.6.1\tools\win64\usr\bin\core_perl;D:\omnetpp-5.6.1; OMNETPP_ROOT=D:/omnetpp-5.6.1/ OMNETPP_IMAGE_PATH=D:\omnetpp-5.6.1\images

有谁知道我做错了什么?

退出代码 -1073741819 的值等于 0xC0000005 - 访问冲突。但是,您提供的 handleMessage() 不能是该错误的来源。
我强烈建议使用调试器来查找导致该错误的行。为此:

  1. 在调试模式下编译您的项目。

  2. 在您的 omnetpp.ini 集合中:

    debug-on-errors = true
    
  3. 在调试中开始模拟(即 Run | Debug

模拟的执行将在导致异常的行之前停止。

参考:TicToc Tutorial - 2.3 Debugging