user1561108 user1561108 - 1 month ago 20
C Question

What does this C function declaration mean?

schedule_accept(int fd,
int (*handler)(int, FdEventHandlerPtr, AcceptRequestPtr),
void *data)


Apologies for seeming to avoid searching for an answer here but I don't know what the constructs are in order to search intelligently for them. Specifically I'm interested in what the second parameter means?

My best guess is it's an int (that refers to a memory location) that is composed(?) of a tuple of the three referred to types. Is this correct? If I was only interested in one of these (and I'm right in my description in the first place) how would I refer to it?

Answer
int (*handler)(int, FdEventHandlerPtr, AcceptRequestPtr)

Defines a parameter named handler which is a pointer (hence the *) to a function, which returns an int (hence the "outer" int) and takes three arguments, namely one int, one FdEventHandlerPtr and one AcceptRequestPtr.