The pragma defines how a data structure is packed during the allocation. The attribute has to be inserted above the data structure and affects the packing of the entire structure.
Syntax:
{attribute 'pack_mode' := ' <pack mode value> '}
Insert location: Above the declaration of the data structure
|
Associated packing method |
Description |
---|---|---|
0 |
Aligned |
All variables are allocated to byte addresses. There are no memory gaps. |
1 |
1-byte-aligned |
|
2 |
2-byte-aligned |
There are
|
4 |
4-byte-aligned |
There are
|
8 |
8-byte-aligned |
There are
|
Depending on the structure, there may be no difference in the memory mapping of the
individual modes. For example, the memory distribution of a structure with the {attribute 'pack mode' := '4'}
pragma can correspond to that of {attribute 'pack mode' := '8'}
.
Arrays of structures
If the structures are combined in arrays, then bytes are added at the end of the structure so that the next structure is aligned.




NOTICE

If the “Compatibility layout” option is selected in the symbol configuration and at the same time the attribute
'pack_mode'
is used in the code, then problems can occur due to unintentional memory misalignment.
-
Example 1
-
Example 2
-
Example 3
-
Behavior without
'pack-mode'
-
Negative effects when using
'pack-mode'