调用含参函数不传参数?

sijdnfsad 2015-12-14 09:32:21
看FFT代码是看见以下代码很奇怪,不知道如何理解,感觉是调用了有参数的函数,但是并没有传递参数。请问这样的函数调用的意义在哪里??以下为部分代码:
void func_die(int beg,int c_num,int k,int i)
{

void add(comp_int ,comp_int ,comp_int *);
void sub(comp_int ,comp_int ,comp_int *);
void mul(comp_int ,comp_int ,comp_int *);

int temp_real =0 ,temp_img = 0;
struct comp_int temp1,up,down;

int a,b,p;
a = beg + k;
b = beg + k + c_num/2;
p = k*pow(2,m-1-i);
mul(in[b], w[p], &up);
add(in[a], up, &up);
mul(in[b], w[p], &down);
sub(in[a], down, &down);
in[a]=up;
in[b]=down;

/*temp_real = (((w[p].real*in[b].real)>>15)-((w[p].img*in[b].img)>>15))>>1;
temp_img = (((w[p].real*in[b].img)>>15) + ((w[p].img*in[b].real)>>15))>>1;
temp1.real = (in[a].real + temp_real)>>1;
temp1.img = (in[a].img +temp_img)>>1;
temp_real = (((w[p].real*in[b].real)>>15)-((w[p].img*in[b].img)>>15))>>1;
temp_img = (((w[p].real*in[b].img)>>15) + ((w[p].img*in[b].real)>>15))>>1;
in[b].real = (in[a].real - temp_real)>>1;
in[b].img = (in[a].img - temp_img)>>1;
in[a].real =temp1.real;
in[a].img =temp1.img;*/


}


void add(comp_int a,comp_int b,comp_int *c)//(16,15)+(16,15)->(16,14)
{

c->real=((a.real+b.real)>>1);
c->img=((a.img+b.img)>>1);

}

void mul(comp_int a,comp_int b,comp_int *c)//(16,15)*(16,15)->(16,15)
{

c->real=((a.real*b.real)>>15) -((a.img*b.img)>>15);
c->img= ((a.real*b.img)>>15) +((a.img*b.real)>>15);

}

void sub(comp_int a,comp_int b,comp_int *c)//(16,15)+(16,15)->(16,14)
{

c->real=((a.real-b.real)>>1);
c->img=((a.img-b.img)>>1);

}

附上原代码连接:http://www.codeforge.cn/read/120977/%E5%AE%9A%E7%82%B9FFT.CPP__html
...全文
1016 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
sijdnfsad 2015-12-14
  • 打赏
  • 举报
回复
引用 7 楼 paschen 的回复:
[quote=引用 6 楼 u011412782 的回复:] [quote=引用 5 楼 paschen 的回复:] 那个只是声明,不是函数调用,而且通常应该把他放到该函数前面(虽然在里面也行)
嗯嗯,但是在内部申明函数有什么意义呢??与外面有什么不同?[/quote] 在内部只有当前这个函数可以用,其他函数(在调用函数的上面的)则用不了[/quote] 所噶,那主要作用就还是控制函数作用范围咯?? 非常感谢!
paschen 2015-12-14
  • 打赏
  • 举报
回复
引用 6 楼 u011412782 的回复:
[quote=引用 5 楼 paschen 的回复:] 那个只是声明,不是函数调用,而且通常应该把他放到该函数前面(虽然在里面也行)
嗯嗯,但是在内部申明函数有什么意义呢??与外面有什么不同?[/quote] 在内部只有当前这个函数可以用,其他函数(在调用函数的上面的)则用不了
sijdnfsad 2015-12-14
  • 打赏
  • 举报
回复
引用 5 楼 paschen 的回复:
那个只是声明,不是函数调用,而且通常应该把他放到该函数前面(虽然在里面也行)
嗯嗯,但是在内部申明函数有什么意义呢??与外面有什么不同?
paschen 2015-12-14
  • 打赏
  • 举报
回复
那个只是声明,不是函数调用,而且通常应该把他放到该函数前面(虽然在里面也行)
sijdnfsad 2015-12-14
  • 打赏
  • 举报
回复
引用 3 楼 fly_dragon_fly 的回复:
[quote=引用 2 楼 u011412782 的回复:] [quote=引用 1 楼 fly_dragon_fly 的回复:] 调用了有参数的函数,但是并没有传递参数 是指那一句? 不会是指上面的函数声明吧
是这里: void add(comp_int ,comp_int ,comp_int *); void sub(comp_int ,comp_int ,comp_int *); void mul(comp_int ,comp_int ,comp_int *); 这里是函数的申明??? C语言不允许这样的函数申明吧? 如果是函数申明的话,这样的申明的意义在哪儿呢?[/quote] 不声明 func_die就不能调用这些函数[/quote] 那为什么不在函数外面申明??在内部申明有什么意义?
sijdnfsad 2015-12-14
  • 打赏
  • 举报
回复
引用 1 楼 fly_dragon_fly 的回复:
调用了有参数的函数,但是并没有传递参数 是指那一句? 不会是指上面的函数声明吧
是这里: void add(comp_int ,comp_int ,comp_int *); void sub(comp_int ,comp_int ,comp_int *); void mul(comp_int ,comp_int ,comp_int *); 这里是函数的申明??? C语言不允许这样的函数申明吧? 如果是函数申明的话,这样的申明的意义在哪儿呢?
fly_dragon_fly 2015-12-14
  • 打赏
  • 举报
回复
引用 2 楼 u011412782 的回复:
[quote=引用 1 楼 fly_dragon_fly 的回复:] 调用了有参数的函数,但是并没有传递参数 是指那一句? 不会是指上面的函数声明吧
是这里: void add(comp_int ,comp_int ,comp_int *); void sub(comp_int ,comp_int ,comp_int *); void mul(comp_int ,comp_int ,comp_int *); 这里是函数的申明??? C语言不允许这样的函数申明吧? 如果是函数申明的话,这样的申明的意义在哪儿呢?[/quote] 不声明 func_die就不能调用这些函数
fly_dragon_fly 2015-12-14
  • 打赏
  • 举报
回复
调用了有参数的函数,但是并没有传递参数 是指那一句? 不会是指上面的函数声明吧

70,021

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧