#define update_weight(bits, weight, source, result) \
if (source && result) { \
if ((source ^ result) >= 0) { if (weight++ == (1 << bits)) weight--; } \
else if (weight-- == (-(1 << bits))) weight++; \
}此宏定义是否有意义,请讨论!
if (source && result) { \
if ((source ^ result) >= 0) { if (weight++ == (1 << bits)) weight--; } \
else if (weight-- == (-(1 << bits))) weight++; \
}此宏定义是否有意义,请讨论!
{
if (source && result)
{
if ((source ^ result) >= 0)
{
if (weight++ == (1 << bits)) weight--;
}
else if (weight-- == (-(1 << bits)))
{
weight++;
}
}
}给几个参数加上数据类型即可。inline函数的效率很高,不会比宏差。