我需要使用两个 QLonglong 来比较我硬盘上的一些可用空间我使用这段代码面对这种行为:
if(deviceSize < size);
{
qDebug() << "The device" << device << "has only" << deviceSize << "bytes left";
qDebug() << (deviceSize < size) << deviceSize << size;
}
哪些输出:
The device "disk1s2" has only 217528172544 bytes left
false 217528172544 998054018
作为条件(deviceSize < size)
返回 false 我什至不明白它是如何进入 if()
的?
最佳答案
您的问题在这里:
if(deviceSize < size);
// ^
这意味着无论您有什么条件,该 block 都将始终执行,因为您的条件语句为空。
关于c++ - QLongLong 奇怪比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23811631/