![]() |
|
MISRA C:2012 Rule-6.1: (Required) |
|
||||
![]() | |||||||
Amplification:
The appropriate bit-field types are:
Note: It is permitted to use typedefs to designate an appropriate type.
Example Code:
#pragma PRQA_MESSAGES_OFF 1056
#include "misra.h"
#include "m3cmex.h"
typedef enum { A, B, C } e_t;
struct T01 { char bpc: 3; }; /* 0634 0635 */
struct T02 { signed char bsc: 3; }; /* 0635 */
struct T03 { unsigned char buc: 3; }; /* 0635 */
struct T11 { short bps: 3; }; /* 0634 0635 */
struct T12 { signed short bss: 3; }; /* 0635 */
struct T13 { unsigned short bus: 3; }; /* 0635 */
struct T21 { int bpi: 3; }; /* 0634 */
struct T22 { signed int bsi: 3; }; /* */
struct T23 { unsigned int bui: 3; }; /* */
struct T31 { long bpl: 3; }; /* 0634 0635 */
struct T32 { signed long bsl: 3; }; /* 0635 */
struct T33 { unsigned long bul: 3; }; /* 0635 */
struct T41 { e_t bet: 3; }; /* 0635 */
struct T51 { _Bool bbl: 3; }; /* */
extern int16_t rule_0601( void )
{
return 0;
}
QAC messages that encompass this guideline:
| 0634 | [I] Bit-fields in this struct/union have not been declared explicitly as unsigned or signed. |
| 0635 | [E] Bit-fields in this struct/union have been declared with types other than int, signed int or unsigned int. |
Related rules:
| Dir-1.1 | Any implementation-defined behaviour on which the output of the program depends shall be documented and understood |
| Rule-1.2 | Language extensions should not be used |
|
||
(c) The Motor Industry Research Association, 2012
|
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |