Attribute 'pack_mode'
This attribute pragma specifies how a data structure is packaged during allocation. The attribute must be inserted above the data structure and affects the packing of the whole structure.
Syntax: {attribute 'pack_mode' := '<Value>'}
Sample
{attribute 'pack_mode' := '0'}
TYPE str_Test :
STRUCT
byTest1 : BYTE;
iTest : DINT;
byTest2 : BYTE;
nValue : INT;
END_STRUCT
END_TYPE
In this sample, the pack mode has been set to 0. If you determine the size of the structure in the sample with SIZEOF, you get the value 8.
1 byte + 4 bytes (DINT) + 1 byte + 2 bytes (INT) = 8 bytes
If you set the pack mode to 2 (WordAlignment), you get the value 10 because a padding byte is inserted after each byte. If you set the pack mode to 4 (DWordAlignment), then you get the value 12, because this time three padding bytes are inserted after each byte. A pack mode of 8 (LWordAlignment) does not change anything, because the sample does not use variables that require 8 bytes.
The CX7000 works with the DWordAlignment (pack mode 4) if you do not use the attribute.
For more information about the pack_mode attribute, see: Attribute 'pack_mode'