0

How can I declare f as pointer to function (pointer to pointer to integer, double) to return pointer to pointer to integer ?

I have tried a lot of variants including:

(int**)(f*)(int**,double)
(**int)(f*)(int**,double)
*(int)(f*)(int**,double)
haccks
  • 104,019
  • 25
  • 176
  • 264
Dragos276
  • 55
  • 1
  • 7
  • Hi, I see you're new to SO. If you feel an answer solved the problem, please mark it as 'accepted' by clicking the green check mark. This helps keeping the focus on older questions which still don't have an answer. – Max Truxa Dec 16 '13 at 06:50
  • Hi, done that now, sorry for marking it so late. – Dragos276 Dec 22 '13 at 13:04

5 Answers5

6

That would be:

int**(*f)(int**,double)

Which according to cdecl.org means:

declare f as pointer to function (pointer to pointer to int, double) returning pointer to pointer to int

I don't believe you can put parens around the return type, and the * for the pointer-to-function part needs to be on the left of the declared name.

Mat
  • 202,337
  • 40
  • 393
  • 406
4

The function signature:

int** func(int**, double);

The function pointer declaration:

int** (*f)(int**, double);
Max Truxa
  • 3,308
  • 25
  • 38
2

Here's the answer :

int** (*f)(int**, double)

http://en.wikipedia.org/wiki/Function_pointer#Example_in_C

How do function pointers in C work?

Community
  • 1
  • 1
AntonH
  • 6,359
  • 2
  • 30
  • 40
  • Thanks :) Yeah, pointers to functions are real useful, but twisted. Xolve gives a good breakdown of this one. – AntonH Dec 08 '13 at 22:23
1

Try

int** (*f)(int**, double);
haccks
  • 104,019
  • 25
  • 176
  • 264
1

I read your description, broke it in parts and here it is:

int **     (*f)(  int **,         double)
 ^           ^       ^               ^
 |           |       |               |
 |       pointer to  |               |
 |       function    |               |
 |                   |               |
 |                 pointer to        |
 |                 pointer to        |
 |                 integer           |
 |                                double
 |
 |
return pointer to pointer to integer

Its actually this simple.

You should read C FAQ on Declarations Its explains them in a very simple and comprehensive way.

Xolve
  • 22,298
  • 21
  • 77
  • 125