lua-users home
lua-l archive

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


MSVC 2010 produces the following warnings with patched luaconf.h at /W3

src\lmathlib.c(150): warning C4244: 'function' : conversion from 'double' to 'lua_Number', possible loss of data
src\lmathlib.c(155): warning C4244: 'function' : conversion from 'double' to 'lua_Number', possible loss of data
src\lmathlib.c(214): warning C4244: 'function' : conversion from 'double' to 'lua_Number', possible loss of data
src\lmathlib.c(279): warning C4244: 'function' : conversion from 'double' to 'lua_Number', possible loss of data
src\lobject.c(107): warning C4244: '=' : conversion from 'double' to 'lua_Number', possible loss of data
src\lobject.c(152): warning C4244: 'return' : conversion from 'double' to 'lua_Number', possible loss of data
src\lobject.c(165): warning C4013: 'strtof' undefined; assuming extern returning int
src\lobject.c(165): warning C4244: '=' : conversion from 'int' to 'lua_Number', possible loss of data
src\loslib.c(268): warning C4244: 'function' : conversion from 'double' to 'lua_Number', possible loss of data
src\ltable.c(82): warning C4244: '=' : conversion from 'double' to 'lua_Number', possible loss of data


There are more at /W4.

Anyway, the proposed patch doesn't look trivial. Especially if compared to changes required in Lua 5.1 to do the same.


Alexey.


----------------------------------------
> Date: Tue, 15 Jan 2013 17:24:18 -0200
> From: lhf@tecgraf.puc-rio.br
> To: lua-l@lists.lua.org
> Subject: Re: [ANN] LuaCSP framework: Communicating Sequential Processes in Lua
>
> > I have sent you the files.
>
> Thanks. I've been able to compile Lua 5.2.1 with float as numbers with the
> changes below. It compiles with no warnings under
>
> i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 with -Wall -Wextra
>
> % diff luaconf.h,orig luaconf.h
> 386,387c386
> < #define LUA_NUMBER_DOUBLE
> < #define LUA_NUMBER double
> ---
> > #define LUA_NUMBER float
> 402,403c401,402
> < #define LUA_NUMBER_SCAN "%lf"
> < #define LUA_NUMBER_FMT "%.14g"
> ---
> > #define LUA_NUMBER_SCAN "%f"
> > #define LUA_NUMBER_FMT "%.7g"
> 416c415
> < #define lua_str2number(s,p) strtod((s), (p))
> ---
> > #define lua_str2number(s,p) strtof((s), (p))
> 419c418
> < #define lua_strx2number(s,p) strtod((s), (p))
> ---
> > #define lua_strx2number(s,p) strtof((s), (p))
> 430,431c429,430
> < #define luai_nummod(L,a,b) ((a) - floor((a)/(b))*(b))
> < #define luai_numpow(L,a,b) (pow(a,b))
> ---
> > #define luai_nummod(L,a,b) ((a) - floorf((a)/(b))*(b))
> > #define luai_numpow(L,a,b) (powf(a,b))
> 446a446,449
> > #if defined(lmathlib_c)
> > #define l_tg(x) x##f
> > #endif
> >
>