As in this example, if I call tsub directly from main, output is as expected. If pthread mode is enabled for tsub, this doesn't give expected output.
va_list vobj;
void *tsub (void *arg)
{
printf ("vobj: %d, %f\n", va_arg (vobj, int), va_arg (vobj, double));
return NULL;
}
void print_mydb (char *name, ...)
{
va_list ap;
va_start (ap, name);
va_copy (vobj, ap);
va_end (ap);
}
int main (void)
{
pthread_t tid;
print_mydb ("b10", 6, 5.23);
#if 1
printf ("THREADY!!!!!\n");
pthread_create (&tid, NULL, tsub, (void *)vobj);
pthread_join (tid, NULL);
#else
tsub (NULL);
#endif
return 0;
}
Output for direct tsub call:
vobj: 6, 5.230000
Output for pthread invocation for tsub:
THREADY!!!!!
vobj: 0, 0.000000