Re: ?? warning: ANSI C++ forbids implicit conversion from `void *' in argument passing



>
>   pthread_t thread;
>
>   pthread_create(&thread, NULL, (void*) &doSimulation, NULL);

the correct declaration for a thread function is:

void *the_function_name (void *);

if your function is not declared like that, you will need to cast it:

   pthread_create (&thread, NULL, (void *()(void*)) the_function, NULL);

but its generally a bad idea to be calling functions which have the
wrong prototype.

in ANSI C and C++, you do NOT need to dereference the name of a
function object to use it as a pointer:

   pthread_create(&thread, NULL, doSimulation, NULL);

--p



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]