J
Juggernaut
I am trying to create a p_thread
pthread_create(&threads[k], &attr, Teste, (void *)var);
where var is a char variable.
But this doesnt't work, I get this message:
test.c:58: warning: cast to pointer from integer of different size.
Now I thought that when it was a void I could pass anything? Thing is it
works when I use an int, but in this case I wanted to use a char. It wouldnt
be hard to work around it, but it annoys me because I've heard anything can
be passed as long as its a void.
I have remembered to declare the function:
void *Teste(void *var)
and in the main method that created the thread I have declared the var
variable :
char var;
var = 'A'
and the function itself: void *Teste(void *var)
Now If I were to change the char declaration of var to f.example:
int var;
var = 1;
It works.
Now as I said I get this message:
test.c:58: warning: cast to pointer from integer of different size.
Why? And where does the pointer from integer come from? Theres no integer
involved, Im trying to pass a void thats a char.
If anyone can help me I would highly apriciate it.
pthread_create(&threads[k], &attr, Teste, (void *)var);
where var is a char variable.
But this doesnt't work, I get this message:
test.c:58: warning: cast to pointer from integer of different size.
Now I thought that when it was a void I could pass anything? Thing is it
works when I use an int, but in this case I wanted to use a char. It wouldnt
be hard to work around it, but it annoys me because I've heard anything can
be passed as long as its a void.
I have remembered to declare the function:
void *Teste(void *var)
and in the main method that created the thread I have declared the var
variable :
char var;
var = 'A'
and the function itself: void *Teste(void *var)
Now If I were to change the char declaration of var to f.example:
int var;
var = 1;
It works.
Now as I said I get this message:
test.c:58: warning: cast to pointer from integer of different size.
Why? And where does the pointer from integer come from? Theres no integer
involved, Im trying to pass a void thats a char.
If anyone can help me I would highly apriciate it.