Packing in structures – Rockwell Automation 1789-L10_L30_L60 SoftLogix 5800 System User Manual User Manual

Page 143

Advertising
background image

Rockwell Automation Publication 1789-UM002J-EN-P - December 2012

143

Develop External Routines

Chapter 7

Packing in Structures

Take care when designing user-defined structures that are shared between the
SoftLogix controller and external routines. The packing mechanisms vary
between the Visual Studio compiler and the Logix Designer compiler. This table
and guidelines help illustrate this situation.

Aggregates like arrays and structures start on 4-byte boundaries.
Consecutive BOOLs are bit-packed, as are boolean arrays.
SINTs and BOOLs are one-byte aligned unless noted above.
INT is 2-byte aligned.
REAL and DINT are 4-byte aligned.
Gaps of one or more bytes may exist between items.

This table shows the Microsoft packing for Visual Studio software, version 6.0. If
you are not using this version of Visual Studio software, consult your
documentation for appropriate packing information.

RSLogix 5000 Structure Storage

Member Data Type

Alignment

Packing

Storage

Consecutive BOOLs

4 byte boundaries

bit packed across storage

((N-1 bits / 32) + 1) * 4 bytes

Array <BOOL>

4 byte boundaries

bit packed across storage

((N-1 bits / 32) + 1) * 4 bytes

BOOL

1 byte boundaries

1 per byte of storage

1 byte

SINT

1 byte boundaries

1 per byte of storage

1 byte

INT

2 byte boundaries

1 per 2 bytes of storage

2 bytes

DINT

4 byte boundaries

1 per 4 bytes of storage

4 bytes

REAL

4 byte boundaries

1 per 4 bytes of storage

4 bytes

Array <nonBOOL>

4 byte boundaries

1 per N bytes of storage

(eleSize * eleCount) bytes

<StructureT> (such as, UDT)

4 byte boundaries

1 per N bytes of storage

Ceiling (sizeof(StructureT) / 4) * 4 bytes

Microsoft Win32 Structure Storage (default n=8)

Member Data Type

Alignment

Packing

Storage

BOOL

Min(1,n) byte boundaries

1 per byte of storage

1 byte

Char

Min(1,n) byte boundaries

1 per byte of storage

1 byte

Short

Min(2,n) byte boundaries

1 per 2 bytes of storage

2 bytes

Int

Min(4,n) byte boundaries

1 per 4 bytes of storage

4 bytes

Long

Min(4,n) byte boundaries

1 per 4 bytes of storage

4 bytes

Float

Min(4,n) byte boundaries

1 per 4 bytes of storage

4 bytes

Array <AnyT>

Min(eleAlignment,n) byte boundaries

1 per N bytes of storage

(eleSize * eleCount) bytes

<StructureT> (such as, struct)

Min(largestOfMember,n) byte boundaries

1 per N bytes of storage

Sizeof(StructureT) bytes

Advertising