lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> They are some warnings given by MSVC compiler.
> Using Visual Studio 2010 with waring level 3 active (the default), 3
> warnings are output:
> 
> - lbaselib.c(340): warning C4090: 'function' : different 'const' qualifiers

OK.


> - lstrlib.c(48): warning C4146: unary minus operator applied to
> unsigned type, result still unsigned
> - ltable.c(91): warning C4146: unary minus operator applied to
> unsigned type, result still unsigned

(I know the result is unsigned, that is what we want. It ensures a
defined behavior in case of overflows.)

Do you know how to remove these warnings? Maybe an extra cast to
unsigned?

-   if ((unsigned int)i == -(unsigned int)i)
+   if ((unsigned int)i == (unsigned int)(-(unsigned int)i))

Or maybe this?

+   if ((unsigned int)i == (0 - (unsigned int)i))


-- Roberto