comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: reading unformatted data into a structure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: reading unformatted data into a structure [message #29741 is a reply to message #29733] Tue, 19 March 2002 02:26 Go to previous messageGo to previous message
Nigel Wade is currently offline  Nigel Wade
Messages: 286
Registered: March 1998
Senior Member
Nigel Wade wrote:

> If it was a single write there *may*
> be packing problems in the struct, although the definition above wouldn't
> appear to require any packing, the C compiler could have decided
> otherwise.
>

Sorry to follow up on my own post, but I've just noticed that there is a
potential alignment problem, here:


unsigned short coordSys; /* The coordinate system used:
0 = Geographical lat/long.
1 = Projection */
char projection[32]; /* Projection name (see above) */
int projParam1; /* 1. projection parameter (see above). */

this int may well need to be aligned on a word boundary. If so 16 bits of
padding will have been inserted into the struct by the C compiler to align
it. If the struct is output by a single write this padding will have been
output with the rest of the data.

On the PC, IDL may have been built to allow structs without padding, so the
same aligment problem might not appear in IDL, so reading the struct as a
single item in IDL will store those 16 bits of padding into projParam1, and
all other items in the struct will be similarly offset.

If the struct was part of an array, then a further 16 bits of padding may
have been added at the end of the struct to ensure that the int which is
the first element of the second struct in the array was properly aligned.


--
-----------------------------------------------------------
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Image editing with IDL?
Next Topic: days of the week

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:36:59 PDT 2025

Total time taken to generate the page: 0.23919 seconds