Videos: Structs
slides: struct.pdf |
These videos are about C structs and unions.
- A C struct combines multiple field values into a single value.
- Using . and -> to access fields of a struct.
- How a struct instance is represented in memory, based on the representations and alignment requirements of each field.Note: there is no “Struct 4” video. I counted wrong.
- More details on struct field alignment and sizes, including the interaction with arrays.
- Implementing a linked list in C with struct and pointers, and connecting related C code with this machine representation.
- Another example of machine code that works with structs.
- A struct instance has a value of each of its fields, but a union instance has a value for only one of its fields at a time.
- Using #pragma pack to control struct field alignment, and why you might or might not want to control alignment.Here’s align.c if you’d like to try it on your machine.