Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>When writing code, and thinking about cross-platform support (e.g. for general-use libraries), what sort of consideration is it worth giving to platforms with non-8-bit char?</p> </blockquote> <p>It's not so much that it's "worth giving consideration" to something as it is playing by the rules. In C++, for example, the standard says all bytes will have "at least" 8 bits. If your code assumes that bytes have exactly 8 bits, you're violating the standard.</p> <p>This may seem silly now -- "<em>of course</em> all bytes have 8 bits!", I hear you saying. But lots of very smart people have relied on assumptions that were not guarantees, and then everything broke. History is replete with such examples.</p> <p>For instance, most early-90s developers assumed that a particular no-op CPU timing delay taking a fixed number of cycles would take a fixed amount of clock time, because most consumer CPUs were roughly equivalent in power. Unfortunately, computers got faster very quickly. This spawned the rise of boxes with "Turbo" buttons -- whose purpose, ironically, was to slow the computer down so that games using the time-delay technique could be played at a reasonable speed.</p> <hr> <p>One commenter asked where in the standard it says that char must have at least 8 bits. It's in section <strong><a href="http://c0x.coding-guidelines.com/5.2.4.2.1.html" rel="noreferrer">5.2.4.2.1</a></strong>. This section defines <code>CHAR_BIT</code>, the number of bits in the smallest addressable entity, and has a default value of 8. It also says:</p> <blockquote> <p>Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign.</p> </blockquote> <p>So any number equal to 8 or higher is suitable for substitution by an implementation into <code>CHAR_BIT</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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