在较老的机器上,小于8位的代码相当常见,但其中大多数代码已经死了很多年了.
C and C++ have mandated a minimum of 8 bits for char
, at least as far back as the C89 standard. [Edit: For example, C90, §5.2.4.2.1 requires CHAR_BIT
>= 8 and UCHAR_MAX
>= 255. C89 uses a different section number (I believe that would be §2.2.4.2.1) but identical content]. They treat "char" and "byte" as essentially synonymous [Edit: for example, CHAR_BIT
is described as: "number of bits for the smallest object that is not a bitfield (byte)".]
然而,目前有一些机器(主要是DSP)的最小类型大于8位--最小类型为12位、14位甚至16位是相当常见的.Windows CE做了大致相同的事情:它的最小类型(至少用微软的编译器)是16位.然而,它们确实not将char
视为16位--取而代之的是它们采取(不一致的)方法,根本不支持名为char
的类型.