共用方式為


編譯程式警告 (層級 3, 關閉) C4287

'operator': unsigned/negative 常數不符

未帶正負號的變數用於具有負數的作業中。

此警告預設為關閉。 如需詳細資訊,請參閱 Compiler Warnings That Are Off by Default

範例

下列範例會產生 C4287:

// C4287.cpp
// compile with: /W3
#pragma warning(default : 4287)
#include <stdio.h>

int main()
{
    unsigned int u = 1;
    if (u < -1)   // C4287
        printf_s("u LT -1");
    else
        printf_s("u !LT -1");
    return 0;
}