25

The ISO C Standard requires CHAR_BIT to be at least 8.

With POSIX mandating CHAR_BIT be equal to 8, and (almost?) all networking and communication standards using octets, is there any contemporary C implementation where CHAR_BIT > 8?

(Note: I'm not interested in historic computer architectures using 18 or 36 bit words. It's genuinely a question about C as it is used today on current hardware; think systems with a C99 or later implementation).

dave
  • 4,812
  • 4
  • 25
  • 38
Jens
  • 69,818
  • 15
  • 125
  • 179
  • 6
    Related to http://stackoverflow.com/questions/2098149/what-platforms-have-something-other-than-8-bit-char – Klas Lindbäck Aug 19 '15 at 09:58
  • 4
    IIRC there are DSP chips with 16 bit chars. – wildplasser Aug 19 '15 at 10:02
  • the wide characters, used in several language alphabets is usually 16 bits – user3629249 Aug 20 '15 at 12:45
  • 2
    Yes. Old Cray machines had the equivalent of `CHAR_BIT == 32` (so `sizeof(int) == 1 == sizeof(short) == sizeof(char)`. Modern DSP systems can have `CHAR_BIT == 16`. – Jonathan Leffler Jul 13 '16 at 07:03
  • 5
    The TI compiler for the TMS320C54x (commonly known as the C54x) defines `CHAR_BIT` as 16. See Table 7.1 in the User's Guide: http://www.ti.com.cn/cn/lit/ug/spru103g/spru103g.pdf – Michael Burr Jul 13 '16 at 07:20
  • 5
    It would be interesting to see if there are non-DSP implementations where `CHAR_BIT > 8`. – a3f Jul 13 '16 at 19:38
  • 3
    The XAP processor created by Cambridge Consultants and powering a few billion Bluetooth headsets around the world have CHAR_BIT == 16 – Chris St John Jul 15 '16 at 16:29
  • @ChrisStJohn You should post an answer with a link to the official documentation specifying CHAR_BIT. – 2501 Jul 17 '16 at 08:04
  • Possibly also related to: [this SO post](http://stackoverflow.com/questions/19708810/fixed-char-bit-on-various-systems). – user3078414 Jul 18 '16 at 19:12
  • 1
    Also see [Exotic architectures the standards committees care about](https://stackoverflow.com/q/6971886/1708801) – Shafik Yaghmour Jun 11 '17 at 06:51
  • Related: [Are there machines, where sizeof(char) != 1, or at least CHAR_BIT > 8?](https://stackoverflow.com/q/2215445/12149471) – Andreas Wenzel Jun 01 '23 at 07:05

3 Answers3

31

TMS320C28x DSP from Texas Instruments has a byte with 16 bits.

Documentation for the compiler specifies CHAR_BIT as 16 on page 101.

This appears to be a modern processor (currently being sold), compilers supporting C99 and C++03.

Jens
  • 69,818
  • 15
  • 125
  • 179
2501
  • 25,460
  • 4
  • 47
  • 87
  • 3
    Two outstanding answers making it hard to select a bounty winner. So I rolled a dice... one of you gets the "accept" score, the other the bounty. – Jens Jul 18 '16 at 21:21
26

Another example is Analog Devices' SHARC processor family. Its C implementation, CrossCore Embedded Studio, has CHAR_BIT == 32 and claims to provide freestanding C99 and C++11 conformance.

a3f
  • 8,517
  • 1
  • 41
  • 46
8

Analog Devices' SHARC DSP was already mentioned (CHAR_BIT==32). Let me add that recent SHARC+ cores (I use ADSP-SC589 and CCES toolchain) can run apps written in two modes: CHAR_BIT == 8 or CHAR_BIT == 32. You can even mix'n'match the two modes together in one app. Although I would not recommend this for development in general, I find it useful when porting code.

Petr Vepřek
  • 1,547
  • 2
  • 24
  • 35