Re: Alignment, Cast (more about structs...)
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Fri, 31 Aug 2007 05:57:39 -0400
Keith Thompson wrote:
.... snip ...
CBFalconer <cbfalconer@xxxxxxxxx> writes:
.... snip ...
Imagine a system with 9 bit chars, such that:
sizeof is
====== ==
short 2
int 3
long 4
float 4
double 6
which would require a universal alignment multiple of 12. Note
that I have not specified the maximums for those various types. As
described above there is room for at least two trapping bits,
allowing detection of uninitialized use, etc.
At any rate, the standard has sufficient room to allow all sorts of
memory arrangements with various practical advantages.
Not *all* sorts. In particular, it doesn't allow an implementation to
require a 2-byte type (say short) to be allocated at an odd address,
since it would violate the definition of "alignment". That was the
point I was making above; I don't believe you addressed it.
My first example (preserved above) did. That was not a 2 byte int,
just an int. Also note the size of a double.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com
.
- Follow-Ups:
- Re: Alignment, Cast (more about structs...)
- From: Keith Thompson
- Re: Alignment, Cast (more about structs...)
- From: Richard Tobin
- Re: Alignment, Cast (more about structs...)
- References:
- Alignment, Cast
- From: anon . asdf
- Re: Alignment, Cast (more about structs...)
- From: anon . asdf
- Re: Alignment, Cast (more about structs...)
- From: Eric Sosman
- Re: Alignment, Cast (more about structs...)
- From: Richard Bos
- Re: Alignment, Cast (more about structs...)
- From: Richard Tobin
- Re: Alignment, Cast (more about structs...)
- From: CBFalconer
- Re: Alignment, Cast (more about structs...)
- From: Keith Thompson
- Re: Alignment, Cast (more about structs...)
- From: CBFalconer
- Re: Alignment, Cast (more about structs...)
- From: Keith Thompson
- Alignment, Cast
- Prev by Date: Re: Porting C software
- Next by Date: Re: size_t problems
- Previous by thread: Re: Alignment, Cast (more about structs...)
- Next by thread: Re: Alignment, Cast (more about structs...)
- Index(es):
Relevant Pages
|