lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Lorenzo Donati once stated:
> 
> I have only skimmed over Lua source, so I may be utterly wrong, but I 
> got the impression that no assumption is made on a char being 8-bit (it 
> may well be 16-bit and everything would be ok). The only assumption is 
> that a char is *at least* 8-bit.
> 
> BTW, according to the snippets of the C standards reported by Axel, this 
> assumption may prove wrong, since it seems that the standard doesn't 
> guarantee that a byte or a char can hold at least 8-bit, but this is 
> purely theoretical probably (how many systems nowadays have bytes with 7 
> or less bits? Are there any?)

  According the the C89 Standard (I have the ISO C Standard, which only
differs in section numbering from the ANSI C Standard) section 5.2.4.2.1,
the *minimum* size of a char is 8 bits.  It can be larger.  If you need
chars to be a certain size, you can check the value of CHAR_BIT (number of
bits in a char) or SCHAR_MAX or UCHAR_MAX.

  -spc