On 30/12/13 00:41, James Kuyper wrote:
> On 12/29/2013 03:32 PM, David Brown wrote:
> ...
>> It's a matter of believability. Certainly some people believe in things
>> that others find unlikely, which is fair enough. But if you were to say
>> "I believe the moon is made of cheese", I would not believe that you
>> believe that. Obviously sticking to old-fashioned definitions ...
>
> I'm curious about your labeling of this definition as "old-fashioned". A
> very large fraction of newly written C code is targeted to embedded
> systems. I'm not sure how large that fraction is, but it's large enough
> that, on one memorable occasion, I had considerable trouble convincing
> one guy that it was less than 100%. Many of those embedded systems are
> DSPs with 16 bit bytes. So implementations of C with bytes that are not
> equivalent to octets is a very current issue.
I am an embedded programmer myself - with 8-bit, 16-bit and 32-bit
microcontrollers. I have used DSP's a little, but DSP programming is a
niche area. I don't have any hard numbers, but I think the percentage
of C code written for DSP's is very low, and getting lower as ordinary
microcontrollers replace them. There are lots of DSP devices sold - but
fewer people programming them.
Anyway, these devices do not have 16-bit "bytes" as such. Many types
have 16-bit or 32-bit "chars" - but they are not (normally) referred to
as "bytes". The exception, of course, is the C standards which define
"byte" to be the smallest addressable unit. (Some microcontrollers and
DSP's allow direct addressing of bits, but that uses compiler-specific
extensions to C.) I don't have any DSP datasheets or toolchain manuals
handy, so I am relying on memory here, but with the devices I used,
groups of 16 bits were never referred to as "bytes".
The word "byte" has several definitions, such as the one in the C (and
C++) standards, the one in the IEEE (I've forgotten the number)
standard, and the ones used by various computer manufacturers over the
decades. But the de facto definition used in almost all current
contexts is 8 bits. That is why I say other uses are old-fashioned. The
C standards are written in a rather specific style, with their own
specific definitions of terms that are often consistent with historical
usage rather than current usage. (Compare that to the Java standard,
which I believe defines a "byte" as 8 bits.)
>
>> ... of a term
>> like "byte" isn't quite that extreme - but if you say, without reference
>> or additional qualification, that you believe a reference to a "byte" in
>> current writing might reasonably refer to something other than 8 bits,
>> then I would not take you literally.
>
> So, you consider the definition of "byte" that is provided by the C
> standard to be so thoroughly esoteric (is that the right word to cover
> your objection?) that it would never occur to you that I might consider
> that definition to be authoritative in the context of C code? Unless I
> emphatically told you otherwise (as I am now doing), you:
>
>> ... would assume you are
>> exaggerating, joking, playing the devil's advocate, or otherwise trying
>> to make a point in some way, or perhaps you have misread the question or
>> mistyped the answer. ...
>
> That seems like a rather extreme position to take. It's as if you were
> actively resisting learning the fact (and it IS a fact) that there are
> contexts where some people use the term with a different definition from
> the one you're used to.
>
Fair enough - the context of C standards is a clear exception where
"byte" can mean more than 8 bits, and obviously that is a common case
here (although it is "esoteric" outside the world of c.l.c. and similar
forums).
But even here, how often does the issue of "char" possibly having more
than 8 bits come up when it makes a real-world, practical difference?
It is almost invariably when someone writes code that assumes chars are
8 bits, or assumes the existence of uint8_t, and then one of the
standards experts points out that this might not always be true. (I
don't mean this comment in a bad way - it is a useful thing to be
informed of these details.) And almost invariably, the code the OP is
writing will never be used on a system without 8-bit chars, and the OP
knows this.
And even in the context of machines with more than 8-bit chars, how
often are these referred to as "bytes" without a great deal of
qualification or context to avoid confusion?
Maybe I expressed myself a bit too strongly, but I would certainly be
surprised to read any reference to "byte" here that did not refer to
8-bit bytes, unless there was context to qualify it.