一些方便的按位操作宏定义

一些方便的按位操作符宏定义,在通信中运用十分方便:

#ifndef BIT_TEST
#define BIT_TEST(a, b)          ( 0 != ((a) & (b)))
#endif

#ifndef BIT_SET
#define BIT_SET(a, b)           ((a) |= (b))
#endif

#ifndef BIT_RESET
#define BIT_RESET(a, b)         ((a) &= ~(b))
#endif

#ifndef BIT_MATCH
#define BIT_MATCH(a,b)          (( (a) & (b) ) == (b))
#endif

#ifndef BIT_COMPARE
#define BIT_COMPARE(a,b,c)          (( (a) & (b) ) == (c))
#endif

猜你喜欢

转载自blog.csdn.net/qq_33195791/article/details/81292119
今日推荐