MISRAC2012-Rule-6.1
In this section:
Synopsis
(Required) Bitfields shall only be declared with an appropriate type.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
Bitfields of plain int type were found. This check is identical to MISRAC2004-6.4.
Coding standards
- MISRA C:2004 6.4
(Required) Bitfields shall only be defined to be of type unsigned int or signed int.
- MISRA C:2012 Rule-6.1
(Required) Bit-fields shall only be declared with an appropriate type
Code examples
The following code example fails the check and will give a warning:
struct bad {
int x:3;
};
The following code example passes the check and will not give a warning about this issue:
struct good {
unsigned int x:3;
};