Re: different struct sizes
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Tue, 07 Nov 2006 00:23:44 GMT
jacob navia <jacob@xxxxxxxxxxxxxxxx> writes:
Keith Thompson wrote:
richard@xxxxxxxxxxxxxxx (Richard Tobin) writes:
In article <lny7qoi6j1.fsf@xxxxxxxxxxxxxxx>,In this newsgroup, I can and I do expect words defined in the C
Keith Thompson <kst-u@xxxxxxx> wrote:
sizeof(char) is 1 by definition, that doesn't mean that it's one byte
Yes, it certainly does; that's the C standar's definition of "byte".
Unfortunately any platform will have its own definition of byte, and
though these coincide 99.9% of the time, the difficult cases will be
the ones where it doesn't. The fact that something is true of C's
definition of byte is not very useful when the issue is how it maps
onto the implementation - you can't expect every word to be used with
C's definition in that context.
standard to be used in accordance with the way the C standard defines
them. Anyone using the word "byte" here in some other sense needs to
say so.
The statement was:
sizeof(char) is 1 by definition, that doesn't mean that it's one
byte
If the poster had said:
sizeof(char) is 1 by definition, that doesn't mean that it's one
byte
(as a particular platform defines the word "byte")
I would have had no objection.
Important distinction. When I ported lcc-win32 to a DSP, each
character took two bytes (16 bits) because the machine could not
address odd bytes. Still, sizeof(char) was 1 of course.
Yes, it's an important distinction, and you're blurring it.
Each character took *one* byte (16 bits). One byte happened to be two
octets.
In that environment sizeof(char) == sizeof(short) == sizeof(int).
Only longs were 32 bits.
Perfectly legal, of course. It could cause some interesting problems
with stdio, since it's difficult to distinguish between EOF and a
character that happens to have the same value. But a DSP would
presumably have a freestanding implementation, so stdio support isn't
required.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- Follow-Ups:
- Re: different struct sizes
- From: Richard Heathfield
- Re: different struct sizes
- From: Nagaraj L
- Re: different struct sizes
- References:
- different struct sizes
- From: Borked Pseudo Mailed
- Re: different struct sizes
- From: Christopher Benson-Manica
- Re: different struct sizes
- From: Simias
- Re: different struct sizes
- From: Keith Thompson
- Re: different struct sizes
- From: Richard Tobin
- Re: different struct sizes
- From: Keith Thompson
- Re: different struct sizes
- From: jacob navia
- different struct sizes
- Prev by Date: Re: different struct sizes
- Next by Date: Re: using long long
- Previous by thread: Re: different struct sizes
- Next by thread: Re: different struct sizes
- Index(es):
Relevant Pages
|