-2

__int64在 64 位 AIX 上使用数据类型,在与 0 进行比较的情况下,我得到了奇怪的结果。

代码片段:

__int64 indexExistingPart =  GetValue(); // GetValue always returns -1.

if (indexExistingPart < 0 )
{
    DoSomething(); //control never comes to this part of the code
}

我还尝试将 0 分配给另一个__int64变量并在比较中使用。但是,这也不起作用:

__int64 indexExistingPart =  GetValue(); // GetValue always returns -1.

__int64 temp =0;

if (indexExistingPart < temp )
{
    DoSomething(); //control never comes to this part of the code
}

为什么比较运算符不适用于 64 位整数?有什么解决方法吗?

4

1 回答 1

0

这些症状与您项目__int64中的 typedef一致。unsigned long__int64不是 AIX 提供的类型,至少根据 IBM 文档。)试试这个:

#include <stdint.h> // or #include <sys/types.h>, or #include <inttypes.h>

int64_t indexExistingPart = GetValue();  // or "signed long indexExistingPart ..."

if (indexExistingPart < 0 )
{
    DoSomething();
}
于 2012-08-28T01:09:53.257 回答