This is a question for any embedded C experts. If you declare a union, is that handled completely by the compiler? One thing that I like about PBASIC is the way you can access bits and nibbles of a byte directly. If you declare a union in c like this:
Code:
union pbyte {
struct {
unsigned b0:1;
unsigned b1:1;
unsigned b2:1;
unsigned b3:1;
unsigned b4:1;
unsigned b5:1;
unsigned b6:1;
unsigned b7:1;
};
struct {
unsigned nib0:4;
unsigned nib1:4;
};
unsigned char byte;
};
will there be a performance hit? According the the C specs it will allocate enough room for the biggest item, so the total size should only be a byte. Is it better practice in the long run to just write macros to get/set/clear the bits instead?