今天在看apue是遇到如下代码:
typedef int Myfunc (const char *, const struct stat *, int);
有点迷茫。后续代码:
static Myfunc myfunc;
static int myfunc(const char *, const struct stat *, int);
尝试后,以上两行代码效果相同。------是否就是替换呢?
网上查询到一个例子:
分析如下:
(1): 将fun函数作为参数传入到testf函数中。
(2): testf函数可展开为:void testf(int f(int));
(3): 调用fun函数返回结果。
这个例子感觉不太好,中间使用了一个回调函数。说到这了,就再研究下回调函数吧。