Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you're asking about the size of a <em>primitive</em> type like <code>int</code>, I'd say it depends on the factor you cited.</p> <p>The compiler/environment couple (where environment often means OS) is surely a part of it, since the compiler can map the various "sensible" sizes on the builtin types in different ways for various reasons: for example, compilers on x86_64 Windows will usually have a 32 bit <code>long</code> and a 64 bit <code>long long</code> to avoid breaking code thought for plain x86; on x86_64 Linux, instead, <code>long</code> is usually 64 bit because it's a more "natural" choice and apps developed for Linux are generally more architecture-neutral (because Linux runs on a much greater variety of architectures).</p> <p>The processor surely matters in the decision: <code>int</code> should be the "natural size" of the processor, usually the size of the general-purpose registers of the processor. This means that it's the type that will work faster on the current architecture. <code>long</code> instead is often thought as a type which trades performance for an extended range (this is rarely true on regular PCs, but on microcontrollers it's normal).</p> <p>If in instead you're also talking about <code>struct</code>s &amp; co. (which, if they respect some rules, <em>are</em> <code>POD</code>), again the compiler and the processor influence their size, since they are made of builtin types and of the appropriate padding chosen by the compiler to achieve the best performance on the target architecture.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload