c++ - 在 Omnet++ 中,c++ 认为变量是一个函数

标签 c++ omnet++

我正在使用 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/

相关文章:

c++ - LINUX:可以通过 LAN 进行管道传输吗?如果是这样,是否可取?还有哪些其他选择?

c++ - 如何处理状态转换并将 "if"语句替换为多态类型?

c++ - 替换 LLVM IR 中的指令

c++ - 如何从 Veins Car2X 模拟器中的 TraCIDemoRSU11p 访问 TraCI 命令接口(interface)?

c++ - Omnet 和 Inet 链接错误 : undefined reference to typinfo

c++ - 第二次打印指针值返回错误结果

c++ - 到达定界符时跳到文本文件的下一行

omnet++ - 如何为所有信号节点创建监听器?

c++ - 如何在 veins2.1 中更新车辆的路线?

c++ - 在 VEINS 中成功接收的概率