1

what do you mean by following line ?

void(*fnctn)(void(*)(int *,void **),int(*)(void**,int*));
11
  • 6
    Visit cdecl.org
    – aschepler
    Jan 26, 2011 at 22:43
  • 12
    If that has been taken from any real code, then kill the author. Jan 26, 2011 at 22:45
  • 4
    That means the cat's been on the keyboard again.
    – sbi
    Jan 26, 2011 at 22:46
  • 2
    @sbi: And he somehow wrote valid C code...
    – James
    Jan 26, 2011 at 22:47
  • 3
    @sbi: It was a special cat. An average one programs in Perl.
    – ruslik
    Jan 26, 2011 at 23:01

5 Answers 5

12

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);
4
$ 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> 
1
  • 1
    And for those of us who have to spend a lot of our time in Windows-land, you can always use the online version of CDecl (yes, unfortunately I work in a lot of code that was written by people who love to use declarations only slightly less insane than the one in this question)
    – Dan
    Jan 30, 2011 at 18:52
2

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

1

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.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.