Is CHAR_BIT ever > 8?

2019-01-15 07:00发布

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).

标签: c char byte bit
3条回答
时光不老,我们不散
2楼-- · 2019-01-15 07:24

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.

查看更多
The star\"
3楼-- · 2019-01-15 07:36

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.

查看更多
混吃等死
4楼-- · 2019-01-15 07:42

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.

查看更多
登录 后发表回答