我希望lua_number得到一个浮点而不是一个double.我知道我必须在luaconf.h中改变一些东西,但我不知道是什么.我正在使用Lua 5.2.3和Visual Studio C++.
lhf*_*lhf 11
您需要编辑luaconf.h和更改这些:
LUA_NUMBER 至 floatLUA_NUMBER_SCAN 至 "%f"LUA_NUMBER_FMT 至 "%.7g"l_mathop(x) 至 (x##f)lua_str2number 使用 strtof对于最后两个,您可能需要一个支持(某些)C99标准的C编译器.
在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
Run Code Online (Sandbox Code Playgroud)
这实际上是Lua 5.1的luaconf,但是5.2的conf应该类似。