"Andrew Haley" <andr...@littlepinkcloud.invalid> wrote in message
news:0fWdnfhfNvUYud7N...@supernews.com...
> Rod Pemberton <do_no...@notemailnot.cmm> wrote:
> > "Andrew Haley" <andr...@littlepinkcloud.invalid> wrote in message
> > news:55OdnX4ccq1aUtzN...@supernews.com...
> >> Rod Pemberton <do_no...@notemailnot.cmm> wrote:
> >> > "Mark Wills" <
markrob...@yahoo.co.uk> wrote in message
> >> >
news:ca821896-0ed0-4314...@r4g2000vbn.googlegroups.com...
> >> > [...]
> >> >
> >> >> For the record: A char is the same as a byte.
> >> >
> >> > Is that apparently open-ended claim _just_ for Forth because this is
> >> > c.l.f.?
> >> >
> >
> > Actually, Forth-94 doesn't define a byte, but it says Forth-83 defines
> > it as 8-bits. A C byte is what the Forth specifications call an
> > "address unit".
> >
> >> > Because, if the open-ended claim is for other languages too, like C,
> >> > then you're just wrong. In C, a byte must be the same size as or
> >> > larger than a char.
> >>
> >> Eh? In C a char is the same size as a byte.
> >
> > No, it's not. I just explained it to you. Read the C specifications
> > some time.
> >
> > For C, a char fits into a byte.
>
> No, a _character_ fits into a byte. chars and characters are not the
> same thing.
>
Wrong. 'char' is the C keyword declaring an object to be of type character.
> > A byte is comprised of one or more addressable units of bits
> > sufficiently large to contain a character. On modern 8-bit
> > byte-addressable machines, they are usually implemented as the same
> > size.
> >
> > E.g., let's take a 16-bit word addressable machine with 9-bit
> > characters. In this case, a char in C is 9-bits and C's byte is
> > 16-bits, not 8-bits.
>
> No. A char on such a system is 16 bits. A character may be 9 bits,
> but a char isn't.
>
Wrong. That's a byte, not a char.
> > The size for the char returned by sizeof() will be one(1) by
> > definition even though the char is 9-bits and consumes two 8-bit
> > bytes.
>
> No. On such a system a byte is 16 bits; there are no 8-bit bytes.
I said the C byte is 16-bits. What you mean is that C doesn't have 8-bit
bytes but has 16-bit bytes. That's true. However, the host machine does
have 8-bit bytes, where a C byte of 16-bits consumes two of them.
> All objects in C can be accessed as arrays of chars. When you copy
> one object to another a char at a time, all of the bits of the object
> are copied. This is a fundamental property of C.
>
No. You're _almost_ correct though.
If you replace your use 'char' here with 'byte', you will be. I.e., all C
objects are arrays of bytes. I can quote for you the C specification, C
Rationale, Johnson & Ritchie, Douglas Gwyn, etc. I.e., none mention
'char' while all mention 'byte'.
> > I.e., 0x0000 would be a null, but 0xFE00 (lower 9-bits cleared)
> > would not be. I.e., a null character is not a character in C but a
> > byte. The higher bits are ignored for non-null characters, e.g.,
> > 0x004, 0xFE41, 0xA541, etc, would all be an ASCII 'A'.
>
> Would
>
> char foo = 0xFE41;
> ('A' == foo)
>
> return 1 on such a system? I don't think so. The upper bits of a
> char are not "ignored".
You're confusing what is accessible in the C context with what is outside
it. Within the C context, you can't set foo equal to 0xFE41. C's context
only allows 9-bits to be set. Those upper bits are inaccesable from C.
Rod Pemberton