[previous] MISRA C:2012  Rule-6.2:  (Required) [next] Single-bit named bit fields shall not be of a signed type

Example Code:


#include "misra.h"
#include "m3cmex.h"


struct T02 { signed char         bsc: 1; uint16_t x; };             /*      0635 3660 */
struct T03 { unsigned char       buc: 1; uint16_t x; };             /*      0635      */

struct X02 { signed char            : 1; uint16_t x; };             /*      0635 3665 */
struct X03 { unsigned char       buc: 1; uint16_t x; };             /*      0635      */

struct T12 { signed short        bss: 1; uint16_t x; };             /*      0635 3660 */
struct T13 { unsigned short      bus: 1; uint16_t x; };             /*      0635      */

struct X12 { signed short           : 1; uint16_t x; };             /*      0635 3665 */
struct X13 { unsigned short      bus: 1; uint16_t x; };             /*      0635      */

struct T22 { signed int          bsi: 1; uint16_t x; };             /*           3660 */
struct T23 { unsigned int        bui: 1; uint16_t x; };             /*                */

struct X22 { signed int             : 1; uint16_t x; };             /*           3665 */
struct X23 { unsigned int        bui: 1; uint16_t x; };             /*                */

struct T32 { signed long         bsl: 1; uint16_t x; };             /*      0635 3660 */
struct T33 { unsigned long       bul: 1; uint16_t x; };             /*      0635      */

struct X32 { signed long            : 1; uint16_t x; };             /*      0635 3665 */
struct X33 { unsigned long       bul: 1; uint16_t x; };             /*      0635      */


extern int16_t rule_0602( void )
{
   return 0;
}


QAC messages that encompass this guideline:

3660 Named bit-field consisting of a single bit declared with a signed type.
3665 Unnamed bit-field consisting of a single bit declared with a signed type.



(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