Hi guys
Recently I need a neat way to compare two structures (with bit field), here is what I think it can be done:
Then I just loop through the data array, but every I add/remove a bit field, I need to adjust the SIZE to accommodate, what's the better to do it?
Thanks!
Recently I need a neat way to compare two structures (with bit field), here is what I think it can be done:
Code:
#define SIZE 4
typedef struct{
uint8_t s1 : 1;
uint8_t s2 : 1;
....
uint8_t s32 : 1;
}__STRUCT_FOO__
typedef union {
__STRUCT_FOO__ foo;
uint8_t data[SIZE];
}__UNION__FOO__;
Thanks!
Last edited: