title: C++: Pass struct to PThread
body: <p>So I am trying to pass several values to a thread by using a struct.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>int main()
  {
  
  struct Data
  {
  int test_data;
  int test_again;
  };
  
  Data data_struct;
  data_struct.test_data = 0;
  data_struct.test_again = 1;
  
  pthread_create(&amp;thread, NULL, Process_Data, (void *)&amp;data_struct);
  return 0;
  }
  
  
  void* Process_Data(void *data_struct)
  {
   struct test
  {
      int test_variable;
      int test_two;
  };
  test testing;
  testing.test_variable = *((int *)data_struct.test_data);
  testing.test_two = *((int *)data_struct.test_again);
  }
  </code></pre>
  
  <p>I have left out any code (inluding <code>#include</code>s and thrad joins etc) I think is unnecessary for this question for the sake of simplicity, however if more code is needed please just ask.</p>
  
  <p>The thread worked fine when passing just one integer variable. </p>
  
  <p>This is the error I am getting:</p>
  
  <p>In function 'void* Process_Data(void*): error: request for member 'test_variable' in 'data_struct' which is of a non-class type 'void*' testing.test_variable = *((int *)data_test.test_variable);</p>
  
  <p>And the same for the other variable</p>
  
  <p>Thanks in advance for any advice.</p>