Original Post
I'm trying to write a small cross-platform multithreaded network piece, and I'm having some trouble with my call to pthread_create(). Basically, in the server class, I pass it the void* to a function that is called when a client socket connects. gcc keeps giving me the error: ANSI C++ forbids implicit conversion from `void *' in argument passing Here's come code snippits around where the problem lies: Any clue as to how to get around the error message above? I'm lost... thanks for any help!
#define NULL (0L)
#define BEGIN_THREAD(TH, FX, DT) pthread_create((pthread_t *)&TH, NULL, (void*)FX, (void*)DT)
#define HANDLE pthread_t *
HANDLE *clientHandles;
ClientObjectType **clientClassObjects;
void *connectFunction;
// ... the server run loop (abbreviated)...
void serverRunRoop(void *connectFunction) {
int currentClient=0;
clientHandles=new HANDLE[MAX_CLIENTS];
clientClassObjects=new *ClientObjectType[MAX_CLIENTS];
// ... lots of code snipped ...
clientClassObject[currentClient]=new ClientObjectType();
//error line is below...vvvv
BEGIN_THREAD(clientHandle[currentClient], connectFunction, clientClassObjects[currentClient]);
currentClient++;
//... more code here...
}
// when unraveled from the #defines, the begin thread looks like:
// pthread_create((pthread_t *)&clientHandle[currentClient], NULL, (void*)connectFunction, (void*)clientClassObjects[currentClient]);
//----