I have created an array of structs. I am attempting to pass one element in this array to a thread through pthread_create. I am getting the following errors (they are for the 2 pthread_create calls I have in for loops):
/../a2/main.cpp|117|error: invalid conversion from ‘void (*)(serverDataStruct*)’ to ‘void* (*)(void*)’|
/../a2/main.cpp|117|error: initializing argument 3 of ‘int pthread_create(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*)’|
I have looked all over and it seems that I have the correct syntax. I will post my code below. Can someone please help me?
struct serverDataStruct
{
};
struct clientDataStruct
{
};
void serverFunc(serverDataStruct *serverData);
void clientFunc(int *ticketNum);
struct serverDataStruct serverDataArray[MAX_NUM_SERVERS];
struct clientDataStruct clientDataArray[MAX_NUM_CLIENTS];
int main ( )
{
for(int i = 0; i < numServers; i++) //create servers
{
pthread_create( &serverTID[i], NULL, serverFunc, (void*) &serverDataArray[i]); //PROBLEM LINE*****************************************************************
}
for(int i = 0; i < numCustomers; i++)
{
pthread_create( &clientTID[i], NULL, clientFunc, (void*) &clientDataArray[i]); //PROBLEM LINE*****************************************************************
}
}
void *serverFunc(void *serverData)
{
}
void *clientFunc(void *clientData)
{
}
{}button to format your code neatly.