Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC2004-6.4

In this section:
Synopsis

(Required) Bitfields shall only be defined to be of type unsigned int or signed int.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Bitfields of plain int type were found. This check is identical to MISRAC2012-Rule-6.1.

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;
};