Alignment of data types

The memory layout of a data type is determined by the alignment. Further information on the alignment can be found in the “Alignment” section in the documentation entitled “PLC”.

With the default alignment of 8 bytes it can be ensured that the access to data types functions optimally in terms of runtime and access on different platforms. Deviation from this should only take place in exceptional cases.

The TwinCAT 3 type system marks data types in color.

The TMC editor offers the possibility to specify the memory layout of a data type for a selected alignment.

Alignment of data types 3:

Alternatively, the layout can be manually specified using offsets.

Alignment of data types 4:

If the size of a data type that is used in another data type is changed, then this data type must also be adjusted. The TMC editor offers an appropriate recursive function for this at the data type overview level.

Alignment of data types 5: