INF: How Bitfields Are Stored in Memory

ID Number: Q32841

1.04 2.03 3.00 4.00 5.00 5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

The Microsoft C Compiler versions 5.0, 5.1, 6.0, 6.0a, 6.0ax, and

C/C++ version 7.0 store bitfields from low memory to high memory. For

example, if you have the following declaration

struct x {

unsigned field_one:3;

unsigned field_two:9;

unsigned field_three:5;

};

then "field_one" will be stored in bits 0-2 in the first word,

"field_two" will be stored in bits 3-11 in the same word, and

"field_three" will be stored in bits 0-4 of the second word (because

it cannot fit in the 4 bits remaining in the current word).

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00