This documentation is archived and is not being maintained.

Compiler Warning (level 3) C4018

Error Message

'expression' : signed/unsigned mismatch

Comparing a signed and unsigned number required the compiler to convert the signed value to unsigned.

This warning may be fixed if you cast one of the two types when testing signed and unsigned types.

The following sample generates C4018:

// C4018.cpp
// compile with: /W3
int main() {
   unsigned int uc = 0;
   int c = 0;
   unsigned int c2 = 0;

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

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