MISRA Discussion Forums

Full Version: Rule 6.1
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In the Amplification for Rule 6.1 :

For C99 : The appropriate types are :

1. either unsigned or signed int.
This refers to unsigned int and signed int only OR any other datatype..?

2. Another explicitly signed or explicitly unsigned integer type that is premitted by the implementation.
What all types does this refer to ? Does this refer to unsigned short OR unsigned short int etc.

Please clarify.
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.