Um... the structure needs to be dynamic memory, pthread_create only passes a void*:
Code:
typedef struct mydata {
int some_value;
char buffer[32];
float etc;
double just_because;
} MyData;
void* funct(void* arg)
{
MyData* pdata = (MyData*)arg;
// do something
// free data
free(pdata);
return NULL; // this value can be picked up by pthread_join()
}
int main()
{
pthread_t thr;
MyData* dyn_data;
int sts;
void* ret_sts = NULL;
dyn_data = malloc(sizeof(MyData));
// Fill the members
// call pthread_create
sts = pthread_create(&thr, NULL, funct, dyn_data);
if ( sts < 0 )
{ /* complain */ }
// wait for thread to complete
pthread_join(thr, &ret_sts);
return 0;
}