title: warning: cast from pointer to integer of different size
body: <p>I'm working on socket programming.. 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 server1.c -o server1 -lpthread
  </code></pre>
  
  <p>And I get the warning</p>
  
  <pre><code>warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  </code></pre>
  
  <p>This error comes for the following code</p>
  
  <pre><code>int newsockfd;
  newsockfd = (int)newsockfdd; //this line
  </code></pre>
  
  <p>And I'm using newsockfdd (which is int) in the following chunk of code</p>
  
  <pre><code>if (pthread_create(&amp;threadID[i++], NULL, serverThread, (void *)(intptr_t)newsockfdd) != 0)
      {
          perror("Thread create error");
      }
  </code></pre>
  
  <p>As you can probably tell, the code is not written too well (I am working on making it better). I know that this warning comes because of something to do with the size of int. But I really dunno how to fix it. Before I put in (intptr_t) in the pthread_create statement, it was showing a warning on that line, but that time the warning was</p>
  
  <pre><code>warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  </code></pre>
  
  <p>It seems like there should be a simple fix to this? But I can't find it. I'm using Ubuntu 64-bit. Is that a reason for the warning?</p>