Mail Archives: djgpp/1999/05/13/18:25:24
El día Thu, 13 May 1999 11:12:26 GMT, XXguille AT XXiies DOT XXes (Guillermo
Rodriguez Garcia) escribió:
>>> Like 'char' is always 1 byte.
>>
>>That's not true, either. There are compilers (mostly for embedded
>>systems) where `char' is 32-bit wide.
>
>Then a byte is defined as 32 bits on those systems. You see, a byte is
>not always 8 bits. It may be 4-bit wide, or 7-bit, or whatever. The
>exact definition of byte, for every system, is the minimum addressable
>memory unit.
Quoting from "Rationale for American National Standard for Information
Systems - Programming Language - C" (the ANSI C rationale is a
document which explain and tries to clarify the standard itself):
"All objects in C must be representable as a contiguous sequence of
bytes, each of which is at least 8 bits wide.
A char (or signed char or unsigned char) occupies exactly one byte.
(Thus, for instance, on a machine with 36-bit 'words', a 'byte' can be
defined to consist of 9, 12, 18 or 36 bits, these numbers being all
the exact divisors of 36 which are not less than 8.) These strictures
codify the widespread presumption that any object can be treated as an
array of characters, the size of which is given by the sizeof operator
with that object's type as it operand."
What I said above is also true: a byte can be any width, depending on
the system; but for a conforming C implementation, the host machine
must have at least 8 bits per byte.
Regards,
GUILLE
----
Guillermo Rodriguez Garcia
XXguille AT XXiies DOT XXes (ya sabes :-)
- Raw text -