Difference between revisions of "Packed"

From Free Pascal wiki
Jump to navigationJump to search
m
(Category moved to template)
Line 12: Line 12:
 
   type TPRecord = Packed record ... end;
 
   type TPRecord = Packed record ... end;
 
</syntaxhighlight>
 
</syntaxhighlight>
 
[[Category:Reserved words]]
 

Revision as of 19:26, 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;