title: Why do I get "cast from pointer to integer of different size" error?
body: <p>The following line (pure c) compiles cleanly on <em>windows</em> (win7 64 bits + codeblocks 13 + mingw32) and <em>debian</em> (wheezy 32 bits + codeblocks 10 + gcc) but raises warning on <em>kali</em> (64 bits + codeblocks + gcc). Any comments? I mean, why do I get this warning, though the same line compiles w/o any warning on windows &amp; debian?</p>
  
  <pre><code>void* foo(void *dst, ...) {
      // some code
      unsigned int blkLen = sizeof(int); // this line ok.
      unsigned int offset = (unsigned int) dst % blkLen; // warning here!
      // some code cont...
  }
  </code></pre>
  
  <p>The message in codeblocks is: "<strong>error:</strong> cast from pointer to integer of different size [-Werror=pointer-to-int-cast]"</p>
  
  <p>note: my compiler options are <code>-std=c99 -Werror -save-temps</code> (same on all three systems).</p>
  
  <p>edit 2:
  Though I've managed to have it compiled w/o warning using the preprocessor lines below, 
  @Keith Thompson (see below) has a crucial point about the issue. So, my last decision is using <code>uintptr_t</code> would be a better choice.</p>
  
  <p>edit 1:
  Thanks for everyone replied. As all the replies note, the problem is a 32 bits vs 64 bits issue. I've inserted following preprocessor lines:</p>
  
  <pre><code>#if __linux__   //  or #if __GNUC__
      #if __x86_64__ || __ppc64__
          #define ENVIRONMENT64
      #else
          #define ENVIRONMENT32
      #endif
  #else
      #if _WIN32
          #define ENVIRONMENT32
      #else
          #define ENVIRONMENT64
      #endif
  #endif // __linux__
  
  #ifdef ENVIRONMENT64
      #define MAX_BLOCK_SIZE unsigned long long int
  #else
      #define MAX_BLOCK_SIZE unsigned long int
  #endif // ENVIRONMENT64
  </code></pre>
  
  <p>and then replaced the problem line as:</p>
  
  <pre><code>unsigned int offset = (MAX_BLOCK_SIZE) dst % blkLen;
  </code></pre>
  
  <p>Now, everything seems OK.</p>