我正在使用 Omnet++ 并编写 C++ 代码。我的 ned 文件中有以下声明:
channel Link extends ned.DatarateChannel
{
datarate = 16Gbps; // 32 lines of 2ns clock
delay = 0us;
}
在我模块的 .cc 文件中,我正在编写以下函数:
void InPortAsync::getErrorTimeout(int sx, int sy, int rx, int ry, int dx, int dy, int &routerType, simtime_t &timeout)
{ // find the flight time for packet from this node to the next joint node = TTL in queue
int dir0 =-1;
int dir1 =-1;
int temprx = -1;
int tempry = -1;
int outPort = -1;
int destRouterType, destTimeout;
Link* temp_Channel;
...
}
很明显,我正在声明一个指向名为 temp_Channel 的链接对象的指针。但是,编译器返回以下错误: “temp_Channel”未在此范围内声明
为什么 GCC 不理解我的声明?
提前致谢!
最佳答案
在 NED 文件中声明 Link
channel 与 C++ 代码无关。它不会生成您可以包含在代码中的任何 header 或 C++ 类。事实上,NED 文件只在运行时处理,而不是在编译时处理。
关于c++ - 在 Omnet++ 中,c++ 认为变量是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41963176/