unsigned long uds_calc_key(unsigned long seed)
{
unsigned long temp;
unsigned short int index;
unsigned short int mult1;
unsigned short int mult2;
if(seed == 0)
{
seed = NC_DEFAULT_SEED;
}
else
{}
for (index=0x5D39, temp=0x80000000; temp; temp>>=1)
{
if (temp & seed)
{
index = croshortright(index, 1);
if (temp & NC_UDS_KEYMASK)
{
index ^= 0x74c9;
}
}
}
mult1 = (nc_uds_keymul[(index>>2) & ((1<<5)-1)]^index);
mult2 = (nc_uds_keymul[(index>>8) & ((1<<5)-1)]^index);
temp = (((unsigned long)mult1)<<16)|((unsigned long)mult2);
temp = mulu32(seed,temp);
return temp;
}
我不明白如何在 for 语句中转换该临时值。我将 temp 值定义为uint
,但出现如下错误:
Cannot implicitly convert type 'uint' to 'bool';
我理解在 C++ 中一个零是false
,而任何不是零的都是true
。但据我所知,这并不适用。你能给我一个提示吗?