开发者

Quick question: explain this typedef

typedef开发者_如何学C int py_var_t (void *);

it is used as:

py_var_t *somesymbol


It defines py_var_t to be the type of a function returning int and taking a void* pointer as argument.


This:

typedef int py_var_t (void *);

defines the type of the function as described by @milan1612. Then this:

py_var_t *somesymbol;

creates a pointer to such a function. You could also have created the pointer like this:

int (*somesymbol)(void *);

but use of typedefs is better practice, particularly when the function types get more complicated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜