SyyKee
SyyKee

Reputation: 59

What does this C function signature actually mean?

What does this type signature mean? I can't wrap my head around it

int (*) ( int(*) (int,int*), int * *)

Thanks in advance!

Upvotes: 0

Views: 100

Answers (3)

chux
chux

Reputation: 154280

what this means

int (*) ( int(*) (int,int*), int * *) is a
pointer to function (pointer to function (int, pointer to int) returning int, pointer to pointer to int) returning int

Upvotes: 0

Eric Postpischil
Eric Postpischil

Reputation: 223264

int (*) ( int(*) (int,int*), int * *) is a pointer to a function with return type int and parameter types int(*) (int,int*), int * *

The first parameter type, int(*) (int,int*) is a pointer to a function with return type int and two parameters of type int and pointer to int.

The second parameter type, int * *, is a pointer to a pointer to an int.

So the whole type is a pointer to a function with:

  • return type int,
  • a first parameter of type pointer to a function with return type int, a parameter of type int, and a parameter of type pointer to int, and
  • a second parameter of type pointer to pointer to int.

Upvotes: 1

MikeCAT
MikeCAT

Reputation: 75062

int (*) ( // a pointer to a function that return int
    int(*) (int,int*), // 1st argument is a function pointer (A)
    int * * // 2nd argument is a pointer to a pointer to int
)

(A) is:

int(*) ( // a pointer to a function that return int
    int, // 1st argument is int
    int* // 2nd argument is a pointer to int
)

Therefore, it means a pointer to a function whose return type is int and 1st argument is "a pointer to a function whose return type is int and 1st argument is int and 2nd argument is a pointer to int" and 2nd argument is a pointer to a pointer to int.

Upvotes: 2

Related Questions