title: Factors influencing the size of primitives,their range and running of binaries on different platforms
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2331751/does-the-size-of-an-int-depend-on-the-compiler-and-or-processor">Does the size of an int depend on the compiler and/or processor?</a>  </p>
  </blockquote>
  
  <p>I am using <code>64 bit</code> OS <em>(windows 7)</em> and using <code>Dev C++</code> compiler <em>(32 bit)</em> . I also use <code>Microsoft Visual C++</code> <em>(32 bit)</em> .</p>
  
  <p>I am confused over the size of primitives. <em>(int,char,short etc)</em> 
   Please address my few questions :</p>
  
  <p>•   On what does the size of these data types depend ? I have heard that the sizes vary with the kind of processor , operating system , compiler. Is that so ? If yes , please explain how do they vary.</p>
  
  <p>•   If I am using 64 bit OS and 32 bit compiler , the binary that will be produced will be compatible for both 32 OS and 64 OS  ? Please address this issue properly and give a clear and a precise answer.</p>
  
  <p>•   What are the factors influencing the binary produced on a particular platform ?</p>
  
  <p>•   Suppose a binary is produced with a 32 bit compiler on 32 bit linux , will it be any different on 32 bit windows ?</p>
  
  <p>•   How is the range of a data type like <code>int</code> defined ?  On what factors does it depend ? Earlier I read that it is <code>32767</code> but while using Microsoft visual C++ it is greater than <code>32767</code> . Is the range totally dependent on compiler or it also depends upon the Operating system or what type of processor it is ?</p>
  
  <p>•   Let there be a program :</p>
  
  <pre><code>#include&lt;iostream.h&gt;
  
  using namespace std;
  
  int main() {
   int x;
   cout&lt;&lt;sizeof(x);
  }
  </code></pre>
  
  <p>While using Microsoft Visual C++ 2010 (32 bit) on 32 bit windows , it prints <code>4</code> as the answer. Will this result vary if I run it on 64 bit platform ? In any case give a proper reason with the answer.</p>