[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.188 packed

Synopsis

Description

`packed' is a reserved word. According to ISO-7185 Pascal it can precede `array' and `record' type definitions to indicate that memory usage should be minimized for variables of this type, possibly at the expense of loss of speed.

As a GNU extension, `packed' can also be applied to section 8.2.10.1 Subrange Types.

Conforming to

The reserved word `packed' is defined in ISO-7185 Pascal.

According to ISO standard, only packed arrays of char with lower bound 1 qualify as strings of fixed length. GNU Pascal neither requires `packed' nor the lower bound of 1 here.

Example

 
program PackedDemo;

type MonthInt = packed 1 .. 12; { needs one byte } FastMonthInt = 1 .. 12; { needs four bytes }

FixString10 = packed array [1 .. 10] of Char; FoxyString10 = array [0 .. 9] of Char;

Flags = packed array [1 .. 32] of Boolean; { needs four Bytes }

DateRec = packed record Day: 1 .. 31; { five bits } Month: MonthInt; { four bits } Year: Integer (15) { 15 bits = -16384 .. 16383 } end;

Dates = array [1 .. 1000] of DateRec;

var S: FixString10; T: FoxyString10;

begin S := 'Hello!'; { blank padded } WriteLn (S);

T := 'GNU Pascal'; { GPC extension: this also works. } WriteLn (T) end.

`DateRec' has 24 bits = 3 bytes in total; `Dates' has 3000 bytes.

See also

section 9.187 Pack, section 9.289 Unpack, section 9.257 SizeOf, section 9.5 AlignOf, section 9.26 BitSizeOf.



This document was generated by Frank Heckenbach on May, 10 2002 using texi2html