【问题标题】:How do I declare a user defined function in OMNet++?如何在 OMNet++ 中声明用户定义函数?
【发布时间】:2015-04-21 16:09:12
【问题描述】:

我已经按照文档中的说明在 c++ 文件中声明了一个函数,并在 .ned 文件中调用了它。但它给出了以下错误。

error:expected constructor, destructor, or type conversion before ‘(’ token Define_Function(dijkstra, 1);

以下是我的 c++ 文件。

#include <omnetpp.h>
#include "stdio.h"
#include "Node.h"
#include "cdelaychannel.h"

Define_Function(dijkstra, 1);
double dijkstra(double start = 1){
....
....
}

在我的网络描述文件中,我调用了该函数。

package myproject;

@license(LGPL);
dijkstra(1.0);

为什么会出现错误?

【问题讨论】:

    标签: omnet++


    【解决方案1】:

    如果您想创建一个在 NED 文件中使用它的函数,您必须按照OMNeT++ Manual 中的说明进行操作。示例如下:

    static cNEDValue ned_foo(cComponent *context, cNEDValue argv[], int argc) 
      int a = (long) argv[0];   
      int b = (long) argv[1];   
      return a*b; 
    }
    
    Define_NED_Function(ned_foo,"int ned_foo(int a, int b)");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-13
      • 2015-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多