我正在用opnet模拟一个网络协议。在一个进程块的进程模型中,我用FB编写了这个函数。但是在编译它的时候,给了我:
error: function 'inrpt_timer' must return a value;但它返回的是'intrpt‘。我糊涂了!还有一个问题:我不知道为什么我要把static放在函数定义的第一位。我只是把它放进去,因为预定义的函数也有它。也许问题出在那上面!代码如下:
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;
}发布于 2014-02-06 16:25:31
哈哈,我自己找到的;
当想要返回值时,(在opnet中) "FRET( value );“替换"return value;”
发布于 2014-02-06 16:27:43
I don't know why I should put static at first of function definition.
声明为static的函数意味着它只能从当前编译单元调用。
发布于 2014-06-04 05:52:59
如果代码中包含FIN(...);,则必须使用FOUT;或FRET(...)关闭函数,具体取决于函数是否应返回任何内容。
适用于void func(...) FRET(...);和int/double/Boolean... func(...)的FOUT;
https://stackoverflow.com/questions/21597377
复制相似问题