Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 6.1 Declaration of bitfields with the C90 compiler that accepts the ANSI C diale
#1
Hi.
Is it possible in C90, without violating MISRA Rule 6.1, to declare bitfields defined as an explicitly signed or explicitly unsigned integer type other than the unsigned int and signed int types allowed by the compiler?
According to section 8.6, this is allowed in C99. However, the compiler I use has a setting to accept the ANSI C dialect conforming to X3.159-1989. With this setting enabled, bitfields can have base types that are enumerated or integral types besides int and unsigned int. This matches A.6.5.8 in the ANSI Common Extensions appendix.
With this setting, I think the declaration of bitfields below is a permitted deviation. Is my understanding correct?
Code:
typedef struct
{
    unsigned char bit0 :1;
    unsigned char bit1 :1;
    unsigned char bit2 :1;
    unsigned char dummy :5;
} st_sample;
Reply


Messages In This Thread
Rule 6.1 Declaration of bitfields with the C90 compiler that accepts the ANSI C diale - by tomoko.mabuchi - 23-02-2024, 02:01 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)