Subject: | |
From: | |
Reply To: | |
Date: | Sun, 4 Jan 1998 01:44:58 -0500 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Stan Sieler wrote:
> Victor writes:
> > I need make a program in C/ix to read a dataset of a Turboimage...
> > My problem is with fields defined as I2 in Turboimage.
> Actually, an IMAGE I2, a C/iX "int", and a Pascal "integer" are all
> 32-bit signed integers. (Assuming you didn't put "short" in front
> of the C/iX "int".)
I suspect the underlying problem is that if you define an image dataset
entry in the form of a C/iX struct, you get "strict alignment" on 32-bit
boundaries for an "int", whereas Image and most other languages use or
at least support 16-bit boundaries. For example, if you have an Image
set with items:
FOO1 I1,
FOO2 I2, [...]
you occupy 48 bits of space - 16 for the I1 and 32 for the I2. If you
try to define this in C/iX as a struct of (short foo1, int foo2), then
the C/iX compiler will add 16 bits after foo1 to pad the struct so that
foo2 is on a 32-bit boundary.
And no, unions don't work either (as far as I know); if you want to
deal with an 'int' in it's native form, you'll have to declare it as
a char[3] and memcpy() it to an int to deal with it (and don't forget
to copy it back before you update/put).
Jeff Kell <[log in to unmask]>
|
|
|