Rules for structure data types
Programming languages vary in their level of support for structures, and certain rules and conventions are adopted to map the MQI structures consistently in each programming language:
- Structures must be aligned on their natural boundaries.
- Most MQI structures require 4-byte alignment.
- On IBM i, structures containing pointers require 16-byte alignment; these are: MQCNO, MQOD, MQPMO.
- Each field in a structure must be aligned on its natural boundary.
- Fields with data types that equate to MQLONG must be aligned on 4-byte boundaries.
- Fields with data types that equate to MQPTR must be aligned on 16-byte boundaries on IBM i, and 4-byte boundaries in other environments.
- Other fields are aligned on 1-byte boundaries.
- The length of a structure must be a multiple of its boundary alignment.
- Most MQI structures have lengths that are multiples of 4 bytes.
- On IBM i, structures containing pointers have lengths that are multiples of 16 bytes.
- Where necessary, padding bytes or fields must be added to ensure compliance with the preceding rules.
Parent topic: Structure data types - introduction