Next: Dealing with Alternatives, Previous: Struct Methods, Up: Structuring Data [Contents][Index]
It is often the case in binary formats that certain elements are separated by some data that is not really used for any meaningful purpose other than occupy that space. The reason for keeping that space varies from case to case; sometimes to reserve it for future use, sometimes to make sure that the following data is aligned to some particular alignment. This is known as padding. There are several ways to implement padding in GNU poke. This article shows these techniques and discusses their advantages and disadvantages.
• Esoteric and exoteric padding | External and internal padding. | |
• Reserved fields | Extra space not to be used. | |
• Payloads | Extra space to be used. | |
• Aligning struct fields | Some stuff requires an alignment. | |
• Padding array elements | An useful idiom. |