【发布时间】:2014-04-14 14:10:48
【问题描述】:
如果我这样输入定义:
typedef int (read_proc_t)(char *page, char **start, off_t off,
int count, int *eof, void *data);
定义here
这种技术叫什么?
如果我以这种方式 typedef,这意味着我创建了一个类型read_proc_t;后来,我创建了自己的read-proc-t 版本,即my_read_proc,我有一个这样的结构:
struct test {
read_proc_t read_proc;
}
struct test t;
我可以这样做:
t.read_proc_t = my_read_proc;
这是正确的吗?通常,如果我 typedef read_proc_t 作为函数指针:
typedef int (*read_proc_t)(char *page, char **start, off_t off,
int count, int *eof, void *data);
我必须将my_read_proc 函数地址分配给函数指针,如下所示:
(*t.read_proc_t) = &my_read_proc;
在什么情况下我会选择一个?
【问题讨论】:
标签: c function-pointers typedef