Sujet : The integral type 'byte' (was Re: Suggested method for returning a string from a C program?)
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 24. Mar 2025, 16:59:20
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vrrvgp$1828d$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 21.03.2025 00:10, Keith Thompson wrote:
bart <bc@freeuk.com> writes:
[...]
Look at this one for example:
>
typedef uint8_t byte; // from arduino.h
>
I can only one of reason this exists, which is that 'byte' is a far
nicer denotation.
I agree in this case. "byte" documents what the type is intended for.
I disagree on both above expressed opinions in more than one way.
Byte is a bad term to denote a quantity or an intention. Formerly
a "Byte" was used to carry characters; its size could be anything
from 5 to 9 bit. There was a reason why in international standards
documents there's the 'octet' introduced to unambiguously hint to
an 8-bit quantity. Neither is it good, as we see in practice, to
assume a 'byte' (whatever it actually is) to be able to carry a
character, not even 'char' or 'unsigned char' seem to be able to
accomplish that given the "wide character" types in the context of
Unicode (16 bit, 32 bit) characters and (variable-length) UTF-8
encodings.
Disclaimer: In the early 1990's we supported an include file like
the later coming "types.h" where we defined the sized type typedefs
and (IIRC) also, for "completeness", typedefs like 'byte'. Actually,
and unlike the "sized" types, 'byte' was never used in practice.[*]
Janis
[*] That's why I'm interested to hear about applications where such
a term proved useful (and better suited than 'octet', 'uint8_t', or
some sort of 'char').
[...]