KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
While working with Threads in C, I'm facing the warning "warning: cast to pointer from integer of different size" The code is as follows #include<stdio.h> #include<sys/types.h> #include<stdlib.h> #include<pthread.h> void *print(void *id) { int a=10; printf("My thread id is %ld\n",pthread_self()); printf("Thread %d is executing\n",id); return (void *) 42; } int main() { pthread_t th[5]; int t; int i; int status; void *ret; for(i=0;i<5;i++) { status=pthread_create(&th[i],NULL,print,(void *)i); //Getting warning at this line if(status) { printf("Error creating threads\n"); exit(0); } pthread_join(th[i],&ret); printf("--->%d\n",(int *)ret); } pthread_exit(NULL); } Can anybody explain how to pass an integer to a function which receives (void * ) as a parameter?
Tags (comma-separated)
Save Edits
Cancel