Why does this generate a compiler warning "Signed / Unsigned mismatch" only when compiling under x64?

Consider this code:

LARGE_INTEGER l;
size_t s;
if (s < l.QuadPart) return 1;
return 0;

When it is compiled under x64, it generates a C4018signed / unsigned mismatch compiler warning (ignore the warning of an uninitialized local variable).

A warning is wonderful because QuadPartthere is LONGLONGone that is signed and size_thas no sign.

But when I compile it under 32-bit, is there no warning? How so? Under 32-bit LONGLONGis still signed and size_tnot specified.

+3
source share
1 answer

32- LONGLONG signed __int64, size_t unsigned int. unsigned int , signed __int64, ( ) size_t signed __int64 , .

64- LONGLONG signed __int64, size_t unsigned __int64, size_t LONGLONG, - , , .

+12

Source: https://habr.com/ru/post/1717430/


All Articles