1字节!= 8位的系统? [英] System where 1 byte != 8 bit?

查看:402
本文介绍了1字节!= 8位的系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在读类似的句子

不要依赖 1 个字节的大小为 8 位

don't rely on 1 byte being 8 bit in size

使用 CHAR_BIT 而不是 8 作为常量在位和字节之间进行转换

use CHAR_BIT instead of 8 as a constant to convert between bits and bytes

等等.今天有哪些现实生活系统,这在哪里适用?(我不确定 C 和 C++ 之间在这方面是否存在差异,或者它实际上是否与语言无关.如有必要,请重新标记.)

et cetera. What real life systems are there today, where this holds true? (I'm not sure if there are differences between C and C++ regarding this, or if it's actually language agnostic. Please retag if neccessary.)

推荐答案

在较旧的机器上,小于 8 位的代码相当普遍,但其中大多数已经死去多年了.

On older machines, codes smaller than 8 bits were fairly common, but most of those have been dead and gone for years now.

C 和 C++ 已规定 最少char 8 位,至少早在 C89 标准中..他们将char"和byte"视为本质上的同义词

C and C++ have mandated a minimum of 8 bits for char, at least as far back as the C89 standard. . They treat "char" and "byte" as essentially synonymous

然而,目前的机器(主要是 DSP)中最小的类型大于 8 位——至少 12、14 甚至 16 位是相当普遍的.Windows CE 的做法大致相同:它的最小类型(至少在 Microsoft 的编译器中)是 16 位.他们确实,但是,将 char 视为 16 位 - 相反,他们采用(不符合标准的)方法,即根本不支持名为 char<的类型/code> 完全没有.

There are, however, current machines (mostly DSPs) where the smallest type is larger than 8 bits -- a minimum of 12, 14, or even 16 bits is fairly common. Windows CE does roughly the same: its smallest type (at least with Microsoft's compiler) is 16 bits. They do not, however, treat a char as 16 bits -- instead they take the (non-conforming) approach of simply not supporting a type named char at all.

这篇关于1字节!= 8位的系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆