|
Bit-fields and Bitwise operators
Hi,
Is it possible to use bitwise operators in bit fields?
For example:
typedef struct Mystruct {
unsigned char A :1 ;
unsigned char B :1 ;
} Mystruct;
and assume
struct Mystruct STR_1S, STR_2S, tempSTRS = {0};
then the following line:
tempSTRS = STR_1S & STR_2S;
gives the error:
operants must have integral type: op "&"
One way to overcome the problem is to perform the bitwise operations in each member separelty i.e.
tempSTRS.A = STR_1S.A & STR_2S.A;
tempSTRS.B = STR_1S.B & STR_2S.B;
Is there any other more eficient way?
|