Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
'token' : signed/unsigned mismatch
Remarks
Using the token operator to compare signed and unsigned numbers required the compiler to convert the signed value to unsigned.
One way to fix this warning is if you cast one of the two types when you compare signed and unsigned types.
Example
This example generates C4018 and shows how to fix it:
// C4018.cpp
// compile with: cl /EHsc /W4 C4018.cpp
int main() {
unsigned int uc = 0;
int c = 0;
unsigned int c2 = c; // implicit conversion
if (uc < c) // C4018
uc = 0;
if (uc < unsigned(c)) // OK
uc = 0;
if (uc < c2) // Also OK
uc = 0;
}
See also
Compiler Warning (Level 4) C4388
Compiler Warning (Level 4) C4389