views:

27

answers:

2

I'm working on the open project gridlabd hosted at sourceforge. I was trying to call the create_thread function: static __inline int create_thread(void * (*proc)(void *), void *arg)

I just don't understand for the life of me what in the world void * (*proc)(void *) means.....

As a side note, did stack overflow add an option for Jon Skeet to answer questions as they're typed up live. I just got a notification at the bottom of my screen saying Jon Skeet has answered this just now.

+5  A: 

void * (*proc)(void *) is a pointer to a function which returns void* and accepts void* as an argument.

Kirill V. Lyadvinsky
I thought it was some kind of crazy typecasting that was going on that I didn't understand.
onaclov2000
A: 

It's a pointer to a function, said function taking a void pointer as an argument and returning a void pointer.

In other words, you can do:

void *threadMain (void *arg) { while (1) doSomething(); }

int stat = create_thread (threadMain, NULL);

to create a thread using the function threadMain as it's procedure.

paxdiablo