// int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); typedef struct { pthread_t *thread; pthread_attr_t *attr; void *(*start_routine) (void *argx); void *arg; int retval; } ptc_arg_t; int the_return_value; void *func(void *arg) { ptc_arg_t *real_args = (ptc_arg_t *)arg; int result = pthread_create(real_args->thread, real_args->attr, real_args->start_routine, real_args->arg); // option void *retval = (void *)&result; return retval; // return pointer to the sack -- bad // option int *tmp = malloc(sizeof(int)); // slow *tmp = result; return (void *)tmp; // user has to free -- can always work & least confusing // option the_return_value = result; // not thread-safe: all threads share one global return NULL; // option *arg = result; // type error return NULL; // option real_args->retval = result; // can work return NULL; // option return (void *)result; // cast 32-bit int as a 64-bit int }