title: Warning: cast to/from pointer from/to integer of different size
body: <p>I'm learning Pthreads.  My code executes the way I want it to, I'm able to use it.  But it gives me a warning on compilation.</p>
  
  <p>I compile using:</p>
  
  <pre><code>gcc test.c -o test -pthread
  </code></pre>
  
  <p>with GCC 4.8.1. And I get the warning</p>
  
  <pre><code>test.c: In function ‘main’:
  test.c:39:46: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       pthread_create(&amp;(tid[i]), &amp;attr, runner, (void *) i);
                                                ^
  test.c: In function ‘runner’:
  test.c:54:22: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     int threadnumber = (int) param;
                        ^
  </code></pre>
  
  <p>This error comes for the following code:</p>
  
  <pre><code>#include &lt;pthread.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  #define MAX_THREADS 10
  
  int sum; /* this data is shared by the thread(s) */
  void *runner(void * param);
  
  int main(int argc, char *argv[])
  {
    int num_threads, i;
    pthread_t tid[MAX_THREADS];     /* the thread identifiers  */
    pthread_attr_t attr; /* set of thread attributes */
  
    if (argc != 2) {
      fprintf(stderr, "usage:  test &lt;integer value&gt;\n");
      exit(EXIT_FAILURE);
    }
  
    if (atoi(argv[1]) &lt;= 0) {
      fprintf(stderr,"%d must be &gt; 0\n", atoi(argv[1]));
      exit(EXIT_FAILURE);
    }
  
    if (atoi(argv[1]) &gt; MAX_THREADS) {
      fprintf(stderr,"%d must be &lt;= %d\n", atoi(argv[1]), MAX_THREADS);
      exit(EXIT_FAILURE);
    }
  
    num_threads = atoi(argv[1]);
    printf("The number of threads is %d\n", num_threads);
  
    /* get the default attributes */
    pthread_attr_init(&amp;attr);
  
    /* create the threads */
    for (i=0; i&lt;num_threads; i++) {
      pthread_create(&amp;(tid[i]), &amp;attr, runner, (void *) i);
      printf("Creating thread number %d, tid=%lu \n", i, tid[i]);
    }
  
    /* now wait for the threads to exit */
    for (i=0; i&lt;num_threads; i++) {
      pthread_join(tid[i],NULL);
    }
    return 0;
  }
  
  /* The thread will begin control in this function */
  void *runner(void * param)
  {
    int i;
    int threadnumber = (int) param;
    for (i=0; i&lt;1000; i++) printf("Thread number=%d, i=%d\n", threadnumber, i);
    pthread_exit(0);
  }
  </code></pre>
  
  <p>How can I fix this warning?</p>