I have
client_sock = accept(server_sock, (struct sockaddr *)&client_name, &client_name_len);
if (pthread_create(&newthread , NULL, (void * ) accept_request, client_sock) != 0) {
perror("pthread_create");
}
That’s just part of the entire script. Every time I try to compile it, I get warning: passing argument 4 of 'pthread_create' makes pointer from integer without a cast
Any idea why this is happening? Thanks in advance.
Argument 4 is
client_sock, which is the argument that gets passed toaccept_request. It is expected to be a pointer, but since it’s just passed through to your function, it can be an integer without doing any harm. Just cast it tovoid*to remove the warning.On the other hand, the third argument
accept_requestshould be a function pointer acceptingvoid*and returningvoid*. You shouldn’t have to cast it tovoid*. It would be best to change the declaration ofaccept_requestto match the specification.