我正在使用opnet模拟网络协议。在过程块的过程模型中,我在FB中编写了此功能。但是在编译时,给我:
error: function 'inrpt_timer' must return a value;
,但它正在返回" Intrpt"。我很困惑!还有另一个问题:我不知道为什么我应该在功能定义的首先放置静态。我只是把它放了,因为预定义的功能也具有它。也许问题在于!这是代码:
static int intrpt_timer()
{
int intrpt;
FIN(intrpt_timer());
if((op_sim_time()-last_time)>=Ts) //check for interrupt
{
intrpt=1;//1 is true
last_time=op_sim_time(); //if timer passed update last time value
}
else
intrpt=0;//zero is false
return intrpt;
FOUT;
}
哈哈,我自己找到了;
当想要返回值时(在opnet中)" fret(value);"替换"返回值;"
I don't know why I should put static at first of function definition.
声明static
的函数意味着它只能从当前汇编单元调用。
如果您的代码中有FIN(...);
,则必须使用FOUT;
或FRET(...)
关闭功能,具体取决于功能是否应返回任何内容。
FOUT;
for void func(...)
FRET(...);
用于int/double/Boolean... func(...)