-2

64ビットAIXでデータ型を使用して__int64いますが、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少なくともIBMのドキュメントによれば、AIXによって提供されるタイプではありません。)代わりにこれを試してください。

#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 に答える