lua-users home
lua-l archive

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


On Fri, Dec 12, 2003 at 02:13:36PM -0200, Luiz Henrique de Figueiredo wrote:
> >Editting lua.h to change the typedef went smoothly.  I ended up with a
> >number of warnings about lost precision, but some static_cast and c-style
> >casts to lua_Number took care of that.  
> 
> There's no need to edit lua.h. As mentioned in config, it is enough to
> add this to config:
> 
> NUMBER= -DLUA_USER_H='"../etc/luser_number.h"' -DUSE_FLOAT
> 
> I don't get *any* warnings with this. Are you using Lua 5.0?
> --lhf

I am not using a vanilla Lua 5.0 distribution.  I am using the Lua 5.0
distribution included with build 1078 of LuaPlus.  It does not include the
luser_number.h file, which makes me wonder what else I'm missing.  Time to
do a diff, I guess.  

I'm sorry that I did not mention that most of my warnings were in the
LuaPlus code, if I recall correctly.  My message was intended to help
those LuaPlus users considering the switch from double to float.  There 
were instances in the LuaObject wrapper where, for an example, an int is 
implicitly cast to a lua_Number.  Code like this:

    unsigned long foo = 0;
    float bar = foo;

issues the following warning in my compiler:

warning C4244: 'initializing' : conversion from 'unsigned long' to
'float', possible loss of data.  

I took a look at each case and decided that the risk of loss of data was
ok for my purposes.  I simply put in explict casts to silence those 
warnings rather than use pragmas, which would have then hid all future 
warnings.


As far as why I editted lua.h directly... 
I  debated about including my reasons for editing lua.h in my previous
email. :)  This time I'll explain my thinking...
I originally did decide to define LUA_NUMBER, but found that there was no 
way to do it for my entire solution. (I'm using .NET).  I could only 
define it on a project-by-project basis.  I was afraid another programmer 
on my team would add a new project and forget to set the define.  Rather
than risk that, I just went ahead and editted the file.  (If someone knows
a way to set a solution-wide define in .NET 2002, let me know)

scott

--