I use macros defined in a header file to handle bit set and clear:
/* a=target variable, b=bit number to act upon 0-n */
#define BIT_SET(a,b) ((a) |= (1ULL<<(b)))
#define BIT_CLEAR(a,b) ((a) &= ~(1ULL<<(b)))
#define BIT_FLIP(a,b) ((a) ^= (1ULL<<(b)))
#define BIT_CHECK(a,b) (!!((a) & (1ULL<<(b)))) // '!!' to make sure this returns 0 or 1
/* x=target variable, y=mask */
#define BITMASK_SET(x,y mask) ((x) |= (ymask))
#define BITMASK_CLEAR(x,y mask) ((x) &= (~(ymask)))
#define BITMASK_FLIP(x,y mask) ((x) ^= (ymask))
#define BITMASK_CHECK_ALL(x,y mask) (!(~(x) & (ymask)))
#define BITMASK_CHECK_ANY(x,y mask) ((x) & (ymask))