我有以下代码:
const uint8_t HEADER_SIZE = 0x08;
std::vector<uint8_t> a, b;
uint8_t x;
/* populate 'a', 'b'. Set 'x' */
for ( uint8_t i = 0; i < HEADER_SIZE; ++i )
{
// The if statement (specifically the AND): Conversion to 'unsigned int' from 'int' may change the sign of the result [-Wsign-conversion]
if ( x != ( a[i + HEADER_SIZE] & b[i] ) )
{
/* ... */
break;
}
}
我尝试了几乎所有内容,但我似乎无法弄清楚为什么一个简单的 AND 会导致此警告。两个变量都是无符号的。有任何想法吗?