Re: Alignment, Cast (more about structs...)



Keith Thompson wrote:

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.

.... snip ...

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

.



Relevant Pages

  • Re: Automatically generate variables
    ... CBFalconer wrote: ... snip ... ... int main ... using either form may fail to be processed. ...
    (comp.lang.c)
  • Re: Good Tutorials
    ... CBFalconer writes: ... snip ... ... Sorry, but a short int is exactly two bytes, and in order to use ... Keith Thompson kst-u@xxxxxxx ...
    (comp.lang.c)
  • Re: Converting to/from pointer
    ... CBFalconer wrote: ... snip ... ... subset of Tibetan that is legal C++. ... functions returning int, including every main. ...
    (comp.lang.c)
  • Re: Mathematics of the Enigma cipher?
    ... snip ... ... int GetCurrentPos ... int CharacterMap(char Char) ... Chuck F (cbfalconer at maineline dot net) ...
    (comp.programming)
  • Re: Float comparison
    ... snip ... ... trying to get an exact definition of them. ... speaking of the usual fp-system which normalizes everything in ... Chuck F (cbfalconer at maineline dot net) ...
    (comp.lang.c)