level 2
天尊鸿钧
楼主
cpp 代码
#include "ELuna.h"
/**/
#define DEBUG_ENGINE
#ifdef DEBUG_ENGINE
//#pragma comment(lib,"../Lib/Lib/Debug/Lua52")
#pragma comment(lib,"../Lib/Debug/Lua52")
#else
#pragma comment(lib,"../Lib/Release/Lua52")
#endif
extern "C" static int Add(lua_State*L)
{
lua_pushnumber(L, 10);
return 1;
}
extern "C" static int Sub(lua_State*L)
{
lua_pushnumber(L, -10);
return 1;
}
static const struct luaL_Reg testlib[] = {
{ "Add", Add },
{ "Sub", Sub },
{ NULL, NULL }
};
extern "C" __dec
lsp
ec(dllexport) int luaopen_TestDll(lua_State* L)
{
luaL_newlib(L, testlib);
return 1;
}
运行结果如下
C:\Users\chenxu>lua
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
> require("TestDll")
multiple Lua VMs detected
stack traceback:
[C]: in ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
>
2014年06月26日 05点06分
1
#include "ELuna.h"
/**/
#define DEBUG_ENGINE
#ifdef DEBUG_ENGINE
//#pragma comment(lib,"../Lib/Lib/Debug/Lua52")
#pragma comment(lib,"../Lib/Debug/Lua52")
#else
#pragma comment(lib,"../Lib/Release/Lua52")
#endif
extern "C" static int Add(lua_State*L)
{
lua_pushnumber(L, 10);
return 1;
}
extern "C" static int Sub(lua_State*L)
{
lua_pushnumber(L, -10);
return 1;
}
static const struct luaL_Reg testlib[] = {
{ "Add", Add },
{ "Sub", Sub },
{ NULL, NULL }
};
extern "C" __dec
lsp
ec(dllexport) int luaopen_TestDll(lua_State* L)
{
luaL_newlib(L, testlib);
return 1;
}
运行结果如下
C:\Users\chenxu>lua
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
> require("TestDll")
multiple Lua VMs detected
stack traceback:
[C]: in ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
>