Originariamente inviato da Kaamos
Non ho capito, se sizeof ritorna la dimensione in bytes e sizeof(char) ritorna sempre 1, come fa a non essere 8 bit?
"byte" nello standard non vuol dire necessariamente 8 bit
3.5
(1) bit
unit of data storage in the execution environment large enough to hold an object that may have one of two values
(2) NOTE It need not be possible to express the address of each individual bit of an object.

3.6
(1) byte
addressable unit of data storage large enough to hold any member of the basic character set of the execution environment
(2) NOTE 1 It is possible to express the address of each individual byte of an object uniquely.
(3) NOTE 2 A byte is composed of a contiguous sequence of bits, the number of which is implementation-defined. The least significant bit is called the low-order bit; the most significant bit is called the high-order bit.
[C99, §3.5, 3.6]
Ovvero un byte è la più piccola unità di memoria che
- è indirizzabile in maniera univoca (=posso avere un puntatore che punta direttamente ad esso)
- può rappresentare tutti i caratteri "di base" (la descrizione esatta di che caratteri debba contenere il "basic character set of the execution environment" è a [C99, §5.2.1 ¶3])
- è grande almeno 8 bit ([C99 §5.2.4.2.1 ¶1])

... ed effettivamente esistono piattaforme dove char è più di 8 bit... (soprattutto DSP, se si parla di piattaforme tuttora in uso)


(giusto per riferimento: link all'ultima draft pubblica dello standard C99)