user972276
user972276

Reputation: 3053

What does it mean when two voids are in a parameter name in C?

I have a method I need to fill in and one of the parameters is: "void (*destructor)(void*)". Can anyone tell me what this is?

Upvotes: 0

Views: 105

Answers (4)

Mithrandir
Mithrandir

Reputation: 25377

The void (*destructor)(void*) is a function pointer. This means, that you can use it to point to any function, which has void as return value (returns nothing) and expects an generic pointer (void*), which can point to anything.

Upvotes: 1

NPE
NPE

Reputation: 500663

It's pointer to a function that takes a void* as its only argument, and returns nothing.

Upvotes: 0

Michael Kohne
Michael Kohne

Reputation: 12044

That's a function pointer. The function given should have the signature:

void funcname(void*)

The first void is the return type, the second is a pointer to void (in other words, a pointer to who knows what, which the underlying function will presumably cast to some useful type later).

Upvotes: 1

Alok Save
Alok Save

Reputation: 206566

It is a Function pointer.

It stores address of an function which takes a void *(pointer to void) as an input parameter and returns no parameter.

Upvotes: 4

Related Questions