且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将标准容器作为字段添加到 OMNet++ 消息中?

更新时间:2023-10-22 15:03:04

应该是这样的:

cplusplus {{
#include <vector>
typedef std::vector<int> IntVector;
}}

class IntVector {
    @existingClass;
}

message SimpleMsg {
    int this_thing;
    int that_thing;
    IntVector these_things;
}

另一种解决方案"是强制消息编译器兼容 4.x(旧模式).只需在 makefrag 文件中添加以下行

An alternate 'solution' is to force the message compiler into 4.x compatible (old mode). Just add the following line in a makefrag file

MSGC:=$(MSGC) --msg4

但是,您迟早应该转换您的代码.如果您希望您的代码同时使用 OMNeT++ 5.5 和 6.0 进行编译,那么您绝对应该明确指定 MSG 编译器版本.兼容 4.x 或 6.x.

However, sooner or later you should convert your code. If you want your code to compile with both OMNeT++ 5.5 and 6.0 then you should definitely specify the MSG compiler version explicitly. Either to be 4.x or 6.x compatible.