Re: ASSOC and structures don't mix [message #11096] |
Sat, 14 March 1998 00:00 |
mgs
Messages: 144 Registered: March 1995
|
Senior Member |
|
|
In article <6eaa68$n0m@ds2.acs.ucalgary.ca>, Brian Jackel
<jackel@danlon.physics.uwo.ca> wrote:
> Recently some people have remarked that ASSOC is a useful
> tool for I/O. While this is true, there is a subtle problem
> when reading structures from a file that was not written
> using ASSOC. The following script demonstrates what I'm
> talking about. Of course, the obvious workaround is to
> write the files using ASSOC as well, but that is not always
> an option.
>
> ;
> ;IDL script to demonstrate why it's dangerous
> ;to use ASSOC with structures.
> ;
...
> ;because IDL is zero padding the structure to
> ;some multiple of 8 bytes (?). There's actually
> ;only 13 bytes (assuming 4 byte floats).
> ;
> HELP,/STR,{PROBLEM}
>
> END
The structure padding got one of my colleagues a couple weeks ago. He had
a structure that should have taken 130 bytes, but was actually taking 136
on his Sun Ultra (64-bit OS) and 132 bytes on my Mac (32-bit OS). I'm not
sure of the exact rules, but basically a structure will be padded to a
multiple of the number of bits of the OS.
--
Mike Schienle Interactive Visuals
mgs@sd.cybernex.net http://ww2.sd.cybernex.net/~mgs/
|
|
|