CHAPTER 9 : Data Usage
PART 4 : USAGE
CHAPTER 9 : Data Usage
9.1 Declarations
9.2 Using floating point numbers
9.3 Using 'typedef'
9.4 Using global data
9.5 Using Structures
9.6 Using Unions
9.7 Using Arrays
9.8 Using Pointers
9.9 Using bit structures
9.10 Using Constants
9.11 Using 'static' declarations
9.12 Initializing variables
9.13 Summary
<--Prev page | Next page -->
9.6 Using Unions
Unions, by definition, operate at the hardware level, where they can be very
useful where it is necessary to map an item in alternative ways. For example,
where a 16-bit register may also be addressed as two individual 8-bit registers:
union HL_REGISTER
{
int Reg16;
struct
{
char LowReg8;
char HighReg8;
} HiLo;
};
Unions are often non-portable, and should thus be used only where necessary,
in isolated, implementation-specific parts of the code.
<--Prev page | Next page -->
|