how do you get the *real* size of a structure? [message #265] |
Fri, 13 March 1992 07:53 |
alans
Messages: 12 Registered: September 1991
|
Junior Member |
|
|
Hi all,
I find myself in a situation which must be fairly common among IDL/WAVE users.
I'm attempting to read a data file with a variable-length header, and then
regularly spaced blocks of binary data. So far I can dynamically create a
structure for the header, and then define an "assoc" variable to the file at
a byte offset which is equal to the length of the header. Since my program
computes the size of the header, my specific problem is, in fact, solved, but...
When I first attempted to do this, I thought I'd be able to obtain the size
of a structure type by using the "size" function. Unfortunately, the size
function doesn't work as well on structures as on arrays. (It returns
[1, 1, 8, 1] for any simple structure, in fact, though arrays of structures
are handled a bit better). So finally, I ask you:
"How can a program extract the (byte) size of a structure?"
("help,/st" can print it out, so it's gotta be available, right :)
Also, please note that looping through each tag and adding up the sizes
of each member (kinda like the example in section 8.6) won't do it, because
IDL pads out to longwords sometimes, at least on the sun4 4.1.1 version I have.
Thanks in advance for any clues.
--
Alan J.Stein MIT/Lincoln Laboratory alans@ll.mit.edu
|
|
|