Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Pascal/HP-UX Programmer's Guide > Chapter 5 Allocation and Alignment

Packed Records

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Table 5-6 “Allocation and Alignment of Packed Record Fields (HP Pascal Packing Algorithm) ” shows how the HP Pascal packing algorithm allocates and aligns the fields of a packed record. The field types are in alphabetical order.

Table 5-6 Allocation and Alignment of Packed Record Fields (HP Pascal Packing Algorithm)

Field Type

Allocation

Field Alignment

Anyptr

8 bytes

4-byte

Array, crunched

Minimum number of bits required to represent any value of the element type.

Bit

Array, packed

Use formula in “Arrays ” section and then pad to alignment boundary.

Same as element or byte, whichever is larger.

Array, unpacked

Use formula in “Arrays ” section and then pad to alignment boundary.

Same as element.

Bit16

2 bytes

Bit

Bit32

4 bytes

4-byte

Bit52

8 bytes

4-byte

Boolean

1 bit

Bit

Char

1 byte

Bit

Enumeration

See “Enumerations and Subranges ”.

File

See “Files ”.

8-byte

Function

8 bytes

4-byte

Integer

4 bytes

4-byte

Globalanyptr

8 bytes

4-byte

Localanyptr

4 bytes

4-byte

Longint

8 bytes

4-byte

Longreal

8 bytes

8-byte

Pointer

4 bytes

4-byte

Procedure

8 bytes

4-byte

Real

4 bytes

4-byte

Record, packed

Fields are allocated by type, and record is padded to the alignment boundary.

Largest alignment of any field or byte, whichever is larger.

Record, unpacked

Fields are allocated by type, and record is padded to the alignment boundary.

Largest alignment of any field.

Set

See “Sets ”.

Shortint

2 bytes

2-byte

Strings

See “Strings ”.

4-byte

Subrange

See “Enumerations and Subranges ”.

 

The field that is aligned on the largest boundary determines the alignment of the entire record. For example, if a record has three fields — one byte-aligned field, one 2-byte-aligned field, and one 4-byte-aligned field — the entire record is 4-byte-aligned.

Packing a record has no effect on fields that are unpacked structures.

Example

TYPE
ua = ARRAY [1..4] OF Boolean;
ur1 = RECORD
i : integer;
c : char;
END;
VAR
ur2 : RECORD
c : char;
a : ua;
r : ur1;
END;

pr : PACKED RECORD
c : char;
a : ua;
r : ur1;
END;

The fields in ur2 and pr are allocated and aligned identically.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.