开发者

Can someone explain this?

what do you mean by following line ?

void(*fnctn)(void(*)(int *,void **),int(*)(void**,int*));
开发者_运维问答


What you have essentially is a function pointer 'fnctn' which takes two function pointers for its two parameters. If we break this down bit by bit, what you have is the following:

The first parameter void(*)(int*, void**) is a function pointer returning void and taking an int* and void** as it's two parameters.

The second parameter int(*)(void**, int*) is a function pointer returning an int value and taking a void** and an int* as its two parameters.

Maybe it's clearer to see as follows:

typedef void(*param1)(int *, void**);
typedef int(*param2)(void**, int*);
typedef void(*fnctn)(param1, param2);


$ cdecl
Type `help' or `?' for help
cdecl> explain void(*fnctn)(void(*)(int *,void **),int(*)(void**,int*));
declare fnctn as pointer to function (pointer to function (pointer to int, pointer to pointer to void) returning void, pointer to function (pointer to pointer to void, pointer to int) returning int) returning void
cdecl> 


Wow, well, a typedef or two would be nice here, but it says...

declare a pointer to a function that returns void with the identifier "fnctn" that takes as parameters a function that returns void and takes an int* and a void** as parameters as well as a function that returns an int which takes a void** and an int* as parameters.

Further reading: Function pointer syntax


Try learning the clockwise spiral rule: http://c-faq.com/decl/spiral.anderson.html With this, you can learn what just about any function declaration will mean, thus enabling you to determine what it does.


Looks to me like declaration of a function pointer to a function that takes a function pointer to a function that takes int*, void** as arguments and returns void as the first parameter, and a function pointer to a function that takes void**, int* as arguments and returns int as the second parameter. This function is of return type void.

Clear as mud.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜