DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Complying with standard C

Bit-fields

The same situation applies to the promotion of bit-field values. In ANSI C, if the number of bits in an int or unsigned int bit-field is less than the number of bits in an int, the promoted type is int; otherwise the promoted type is unsigned int. In most older C compilers, the promoted type is unsigned int for explicitly unsigned bit-fields, and int otherwise.

On machines where plain bit-fields represent unsigned values, full-sized bit-fields (for example, 8 bit chars, 16 bit shorts, 32 bit ints, longs, and enums) will be changed for the purpose of code generation to the corresponding unsigned type. Any full-sized bitfield, on any machine, will be changed to a simple type.

Similar use of casts can eliminate situations that are ambiguous.


Next topic: Second example: result is the same
Previous topic: First example: using a cast

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005