是否有替代语法来设置typedef函数指针?

Ank*_*kit 6 c typedef function-pointers

为了做一个函数指针的typedef,我们做这样的事情,

typedef int (*func) (char*);
typedef struct{
  char * name;
  func f1; 
}
Run Code Online (Sandbox Code Playgroud)

与此相反,我遇到了一个我不明白的代码.

typedef int rl_icpfunc_t (char *);
typedef struct {
   char *name;         /* User printable name of the function. */
   rl_icpfunc_t *func; /* Function to call to do the job. */
   char *doc;          /* Documentation for this function.  */
}COMMAND;
Run Code Online (Sandbox Code Playgroud)

这是libedit库示例的代码片段.有人可以向我解释一下吗?

alk*_*alk 8

typedef int rl_icpfunc_t (char *);
Run Code Online (Sandbox Code Playgroud)

将函数原型定义为类型.

rl_icpfunc_t * func; 
Run Code Online (Sandbox Code Playgroud)

定义func为指向前者的指针.

这与通过以下方式直接定义函数指针类型相反:

typedef int (*prl_icpfunc_t) (char *);
prl_icpfunc_t func;
Run Code Online (Sandbox Code Playgroud)

两个approches的结果是相同的:一个指针func,指向一个函数返回int并取一个参数,即a char*.