title: Should the thread function return 0?
body: <p>I have this void function, with a pointer to my thread. when i go to compile, I get the warning: "control reaches end of non-void function". If I do </p>
  
  <pre><code>void mythread (void *arg)
  </code></pre>
  
  <p>and the function i will solve the warning that the compiler gives, but get a new warning, that says:</p>
  
  <pre><code>TA.c:50:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default]
  </code></pre>
  
  <p>So then, I put <code>return 0;</code> at the end of "mythread" function, and it compiles. But I'm not sure if this is the right thing to do?</p>
  
  <p>I am trying to learn POSIX system service programing. I am not sure what to do.</p>
  
  <p>Advice? Should I try and type cast argument 3? How can I compile my program, and get zero warnings? </p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;limits.h&gt;
  #include &lt;pthread.h&gt;
  #include &lt;stdio.h&gt;
  
  void *mythread (void *arg)
  {   
      printf("This my Thread Maybe...\n");    
  }
  
  int main()
  {
      pthread_t mythread_id;
      pthread_attr_t mythread_attr;
      size_t stack_size;
      int detachstate;
  
      pthread_attr_init (&amp;mythread_attr);
      pthread_attr_getdetachstate(&amp;mythread_attr, &amp;detachstate);
      if(detachstate == PTHREAD_CREATE_DETACHED)
      {
          printf("Current Deteached state is Detached\n");
      }
      else
      {
          printf("Current Detached state is Joinable\n");
      }
  
      pthread_attr_setdetachstate (&amp;mythread_attr, PTHREAD_CREATE_DETACHED);
      pthread_attr_getdetachstate (&amp;mythread_attr, &amp;detachstate);
  
      if(detachstate == PTHREAD_CREATE_DETACHED)
      {
          printf("NEW DETACHED STATE is determined to be deteched\n");
      }
      else
      {
          printf("NEW DETACHED STATE is Determine to be Joinable\n");
      }
  
      pthread_attr_getstacksize (&amp;mythread_attr, &amp;stack_size);
      printf ("Default stack size is %d; minimum is %d\n", stack_size, PTHREAD_STACK_MIN);
      pthread_attr_setstacksize (&amp;mythread_attr, PTHREAD_STACK_MIN*2);
      pthread_attr_getstacksize (&amp;mythread_attr, &amp;stack_size); 
  
      printf("NEW stack size is %d\n", stack_size);
      pthread_create (&amp;mythread_id, &amp;mythread_attr, mythread, 0);
  
      return 0;
  }
  </code></pre>