【发布时间】:2011-09-11 17:06:03
【问题描述】:
例如:
#include <stdio.h>
typedef void (* proto_1)();
typedef void proto_2();
void my_function(int j){
printf("hello from function. I got %d.\n",j);
}
void call_arg_1(proto_1 arg){
arg(5);
}
void call_arg_2(proto_2 arg){
arg(5);
}
void main(){
call_arg_1(&my_function);
call_arg_1(my_function);
call_arg_2(&my_function);
call_arg_2(my_function);
}
运行这个我得到以下信息:
> tcc -run try.c
hello from function. I got 5.
hello from function. I got 5.
hello from function. I got 5.
hello from function. I got 5.
我的两个问题是:
- 使用
(* proto)定义的函数原型与未定义的函数原型有什么区别? - 使用引用运算符 (
&) 和不使用引用运算符调用函数有什么区别?
【问题讨论】:
-
我认为没有区别。没有发布作为答案,因为我不太确定。
标签: c function functional-programming operators