I am looking for which of the following code examples are the preferred method to set and clear flags in C and why.
int main()
{
#define FLAG5 0x10 // 0001 0000
#define SET_Flag5 Flags |= FLAG5
#define CLR_Flag5 Flags &= ~FLAG5
SET_Flag5;
CLR_Flag5;
}
or this method
int main()
{
#define Set_Flag5 Flags = (Flags & 0xffef) | 1 << 4
#define Clr_Flag5 Flags = (Flags & 0xffef) | 0 << 4
Set_Flag5;
Clr_Flag5;
}
Thanks Roy