This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

bitfields in bdata behaviour

Hello,

If a bdata variable is defined in the form:

struct foo
{
   unsigned char b1:1;
   unsigned char b2:1;
   unsigned char b3:1;
   unsigned char b4:1;
   unsigned char b5:1;
   unsigned char b6:1;
   unsigned char b7:1;
   unsigned char b8:1;
} bdata myflags;

Will the code:

if (myflags.b3)
   // do something

or the code:

myflags.b5 = 1;

generate the efficient 8051 code using jb, setb, etc?

I will do some testing myself, but in the meantime I'd like to know your ideas and advices.

I am porting some C code to Keil C51 and I am wondering if I can avoid the use of the bit and sbit keywords which are heavy extensions to C.

Thanks,
Nestor

Parents Reply Children