This chapter deals with C structures and unions. Some other languages call these records. Structure definitions are covered along with the use of tags and typedefs. The advanced topics of nested structures and bit fields are fully explained with examples. The differences between unions and structures are taught in this chapter.
The layout of structures and unions in memory is shown, as well as the use of the packed attribute. This chapter has many examples to show how structures can be best used in embedded programs for microcontrollers.
Examples and exercises are for the popular PIC™ microcontroller manufactured by Microchip.