我希望lua_number获得浮标,而不是double。我知道我必须在luaconf.h中更改一些东西,但我不知道什么。我正在使用LUA 5.2.3和Visual Studio C 。
您需要编辑luaconf.h
并更改以下内容:
-
LUA_NUMBER
tofloat
-
LUA_NUMBER_SCAN
to"%f"
-
LUA_NUMBER_FMT
至"%.7g"
-
l_mathop(x)
到(x##f)
-
lua_str2number
使用strtof
对于最后两个,您可能需要一个支持C99标准的C编译器。
in luaconf.h
/*
** {==================================================================
@@ LUA_NUMBER is the type of numbers in Lua.
** CHANGE the following definitions only if you want to build Lua
** with a number type different from double. You may also need to
** change lua_number2int & lua_number2integer.
** ===================================================================
*/
#define LUA_NUMBER_DOUBLE
#define LUA_NUMBER double
这实际上是Lua 5.1 luaconf,但是5.2 conf应该相似。