part of my code:
int server_sockfd, client_sockfd; //socket file descriptors of client and server
// ... some code
if(pthread_create(&vlakno, NULL, handle_client, (int *) client_sockfd) != 0) {
perror("Error while creating thread.");
}
I'm getting "warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]"
prototype of my function:
void *handle_client(void *args);
I found this question:
link
The first answer said something like that he should use intptr_t instead of int.
I have two questions:
What is difference between int and intptr_t in my case?
What should I do?
I have 2 ideas:
1st: (changing type of file descriptors)
int server_sockfd, client_sockfd; //socket file descriptors of client and server
// ... some code
if(pthread_create(&vlakno, NULL, handle_client, (intptr_t *) client_sockfd) != 0) {
perror("Error while creating thread.");
}
or 2nd idea: (changing type only in casting function pthread_create)
intptr_t server_sockfd, client_sockfd; //socket file descriptors of client and server
// ... some code
if(pthread_create(&vlakno, NULL, handle_client, (int *) client_sockfd) != 0) {
perror("Error while creating thread.");
}
EDIT:
in function handle_client i want to do this:
int clientSocket;
clientSocket = (int)args;
I'm really sorry to user cnicar or something like that .. he unfortunatelly deleted his answer but it was ok.
His solution was use (void *), it firstly casted same same error but it was caused probably bad behaviour of eclipse :(
So message for him:
Ok thanks it looks thats fine now ... Eclipse still throwed this warning but when I turned it on and off twice afer edit it fine with your edit :) thanks a lot
&client_sockfd
? – Tigrinya