21-01-2014, 09:17 AM
Paragraph 4 of the constraints section 6.7.2.1 of the C99 standard states:
"A bit-field shall have a type that is a qualified or unqualifed version of _Bool, signed int, unsigned int or some other implementation-defined type."
The phrase "implementation-defined type" refers to both
* standard integer types (excluding unsigned int and signed int)
and
* implementation-defined extended integer types
providing your implementation supports those types in a bit-field declaration.
Going back to your question.
"unsigned and signed int" bit-fields are permitted by all implementations and will always be compliant with this rule.
Other explicitly signed integer types such as "unsigned short" may or may not be compliant with this rule, depending on whether such types are supported as bit-fields by your implementation.
"A bit-field shall have a type that is a qualified or unqualifed version of _Bool, signed int, unsigned int or some other implementation-defined type."
The phrase "implementation-defined type" refers to both
* standard integer types (excluding unsigned int and signed int)
and
* implementation-defined extended integer types
providing your implementation supports those types in a bit-field declaration.
Going back to your question.
"unsigned and signed int" bit-fields are permitted by all implementations and will always be compliant with this rule.
Other explicitly signed integer types such as "unsigned short" may or may not be compliant with this rule, depending on whether such types are supported as bit-fields by your implementation.
Posted by and on behalf of the MISRA C Working Group