Pointer inside a struct / thread

Posted by bruno on Stack Overflow See other posts from Stack Overflow or by bruno
Published on 2010-12-23T16:28:08Z Indexed on 2010/12/23 16:54 UTC
Read the original article Hit count: 203

Hi!
I have this warning "warning: assignment from incompatible pointer type " in this line:

data1->transformed_block[l] = &transformed_block[l];

-

void print_message_function ( void *ptr )  
{  
  dt *data;  
  data = (dt *) ptr;  
  printf("Dentro da thread Numero0: %ld\n", data->L_norm_NewBlock);  
  pthread_exit(0);  
}  

typedef struct data_thread  
{  
    long L_norm_NewBlock;  
    int Bsize_X;      
    int Bsize_Y;  
    int *transformed_block[MAX_LEVEL];  
    long L_norm_OrigBlock;      
} dt;  

void function()  
{  
  int *transformed_block[MAX_LEVEL];  
  pthread_t thread1;  
  dt *data1;  
  pthread_attr_t attr;  
  pthread_attr_init(&attr);

  //Fills structure  
  data1 = (dt *) malloc(sizeof(dt));    
  data1->transformed_block[l] = &transformed_block[l];

  data1->L_norm_NewBlock=0;  
  data1->Bsize_Y = Bsize_Y;  
  data1->Bsize_X = Bsize_X;  

  pthread_create(&thread1, &attr, (void *) &print_message_function, (void *) &data1);  
}

I want to get rid of that warning, and the values i get inside the thread are wrong. For example data1->L_norm_NewBlock=0; in the thread guives me a differente value (not 0 like it should be).

© Stack Overflow or respective owner

Related posts about c

    Related posts about multithreading