Compiler Warning (level 4) C4388

'token' : signed/unsigned mismatch

Using the token operator to compare a signed and a larger unsigned number required the compiler to convert the signed value to the larger unsigned type.


One way to fix this warning is if you cast one of the two types when you compare signed and larger unsigned types.

This warning is off by default. You can use /Wall or /w44388 to enable it on the command line as a level 4 warning. Or, use #pragma warning(default:4388) in your source file. For more information, see Compiler warnings that are off by default.


This sample generates C4388 and shows how to fix it:

// C4388.cpp
// compile with: cl /EHsc /W4 C4388.cpp
#pragma warning(default: 4388)

int main() {
    unsigned long long uc = 0;
    int c = 0;
    unsigned long long c2 = c; // implicit conversion

    if (uc < c)                       // C4388
        uc = 0;

    if (uc < (unsigned long long)(c)) // OK
        uc = 0;

    if (uc < c2)                      // Also OK
        uc = 0;

See also

Compiler Warning (Level 3) C4018
Compiler Warning (Level 4) C4389