lua-users home
lua-l archive

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


On Thu, Oct 28, 2010 at 7:07 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> >> http://msdn.microsoft.com/en-us/library/ke55d167(v=VS.100).aspx ....
> It might be a coincidence, but all cases in your fixes the macro
> 'sizenode' was used in a context where it would naturally be converted
> to size_t. There are other cases where it should (or could) remain an int.

Although it's perfectly valid to implicitly convert an int into a
64-bit size_t, say by multiplying it by another size_t, MSVC -W3 is
complaining with C4334 when that int is formed by a variable left
shift on an integer literal.  However, some trivial operation after
the shift avoids the warning:

  #define twoto(x)	(int)(1u<<(x))   /* note: unsigned->signed cast operation */
  #define twoto(x)	(int)(unsigned int)(1<<(x)) /* similar */
  #define twoto(x)	(0 | 1<<(x))

All of these eliminate the Lua 5.1.4 warnings.  They do seem like hacks though.