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

Home » Public Forums » archive » size of 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: size of a structure [message #7972 is a reply to message #7905] Wed, 29 January 1997 00:00 Go to previous messageGo to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <Pine.SUN.3.91.970129142249.26479C-100000@demsyd.syd.dem.csiro.au>, Peter Mason <peterm@demsyd.syd.dem.csiro.au> writes:
> On Mon, 27 Jan 1997, Phil Williams wrote:
>> 1) What is the "length" of a struture in the help,/st mean? It's not
>> the "size" which is what I thought it was. i.e.
>> IDL> help,/st,info
> < ... structure with several string fields & some other fields, with
> < help,/struct showing length=124 >
> < ... code showing that structure written to disk is 162 bytes long >
>
> It seems that the structure's "length" is correct except when it comes to
> structure members which are strings. A string member contributes 16
> bytes to the structure's "length", regardless of string length.
> This is probably because strings are dynamic, while everything else about
> an IDL structure's size (#members, member datatypes and dimensions) is
> static: the 16 bytes shown for a string member is probably some sort of
> string descriptor with a pointer to the actual string.

Be careful here, you also need to worry about padding. IDL will build its
structures to obey the machine's alignment requirements. For example if you
have a structure:
s = {a: 0, b: 0L}
you might expect the size to be 6 bytes. Indeed, here is the output of IDL run
on a VAX:
IDL> s= {a: 0, b: 0L}
IDL> help, /str, s
** Structure <4767ac>, 2 tags, length=6, refs=1:
A INT 0
B LONG 0

The length is 6.

However, on a machine which requires long integers to be aligned on quadword
boundaries, then there will be 2 bytes of padding between s.a and s.b. Here is
the output of IDL run on a DEC Alpha:
IDL> s= {a: 0, b: 0L}
IDL> help, /str, s
** Structure <47cbc0>, 2 tags, length=8, refs=1:
A INT 0
B LONG 0

Note that length is 8, not 6.

____________________________________________________________
Mark Rivers (773) 702-2279 (office)
CARS (773) 702-9951 (secretary)
Univ. of Chicago (773) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars.uchicago.edu (e-mail)

or:
Argonne National Laboratory (630) 252-0422 (office)
Building 434A (630) 252-0405 (lab)
9700 South Cass Avenue (630) 252-1713 (beamline)
Argonne, IL 60439 (630) 252-0443 (FAX)
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Title , multiple Plot in IDL
Next Topic: Re: KILL_NOTIFY Programs

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

Current Time: Fri Oct 10 14:17:33 PDT 2025

Total time taken to generate the page: 0.80228 seconds