Difference between revisions of "Packed"

From Free Pascal wiki
Jump to navigationJump to search
m (FPC user moved page Packed/en to Packed: drop en suffix)
m
Line 7: Line 7:
 
Example:<br>
 
Example:<br>
 
<syntaxhighlight>
 
<syntaxhighlight>
   type TPArray = Packed array[...] of ...;
+
   type TPArray = Packed array[1 .. 9] of longint ;
 
   type TPClass = Packed class  ... end;
 
   type TPClass = Packed class  ... end;
 
   type TPObject = Packed object ... end;
 
   type TPObject = Packed object ... end;

Revision as of 14:37, 30 October 2017

Deutsch (de) English (en) русский (ru)

The reserved word packed tells the compiler to use as little memory as possible for a particular complex data type. Without specifying packed, the compiler may insert extra unused bytes between members in order to align the data on full word boundaries for faster access by the CPU. So packed sacrifices some speed while reducing the memory used.


Example:

  type TPArray = Packed array[1 .. 9] of longint ;
  type TPClass = Packed class  ... end;
  type TPObject = Packed object ... end;
  type TPRecord = Packed record ... end;