Search code examples
csyntaxxcb

What does 'void (*return_socket)(void *closure);' mean?


I am browsing though the XCB sources and I found this weird struct member:

void (*return_socket)(void *closure);

What does that mean? What's another way to write this?


Solution

  • That is a function pointer. It points to a function that returns void and receives a void * as parameter.

    For example, you could use that as:

    void myFunction(void *closure)
    {
        printf("myFunction called with closure=%p", closure);
    }
    
    void (*return_socket)(void *closure) = myFunction;