Export (0) Print
Expand All
Expand Minimize
0 out of 1 rated this helpful - Rate this topic

Compiler Warning (level 4) C4245

Error Message

'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch

You tried to convert a signed const that has a negative value to an unsigned.

The following sample generates C4245:

// C4245.cpp
// compile with: /W4 /c
const int i = -1;
unsigned int j = i; // C4245

const int k = 1;
unsigned int l = k; // okay

int m = -1;
unsigned int n = m; // okay

void Test(size_t i) {}

int main() {
   Test( -19 );   // C4245
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.