3.12不是很清楚,我用的3.4,是另外下载个以前quick版本的,把里边的quick-src/lua_extensions/cjson源码添加进来,可以在android,ios下编译,VS上用不了,另外还要自己注册到lua
if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
luaopen_lua_extensions_more(L);//CJSON
#endif
lua_extensions_more.c的只留下CJSon功能代码如下:
include "lua_extensions_more.h"
if __cplusplus
extern "C" {
endif
// cjson
include "cjson/lua_cjson.h"
ifndef WP8
// filesystem
endif
static luaL_Reg luax_exts[] = {
{"cjson", luaopen_cjson_safe},
{NULL, NULL}
};
void luaopen_lua_extensions_more(lua_State *L)
{
// load extensions
luaL_Reg* lib = luax_exts;
lua_getglobal(L, "package");
lua_getfield(L, -1, "preload");
for (; lib->func; lib++)
{
lua_pushcfunction(L, lib->func);
lua_setfield(L, -2, lib->name);
}
lua_pop(L, 2);
}
if __cplusplus
} // extern "C"