The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017

Compiler Warning (level 3) C4018


The latest version of this topic can be found at Compiler Warning (level 3) C4018.

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;