MISRA Discussion Forums
Rule 6.1 - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.6 Types (https://forum.misra.org.uk/forumdisplay.php?fid=161)
+---- Thread: Rule 6.1 (/showthread.php?tid=1016)



Rule 6.1 - Akhil - 15-01-2014

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.


Re: Rule 6.1 - misra-c - 21-01-2014

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.