int _tmain(int argc, _TCHAR* argv[]) { Test::Tst_B* b = new Test::Tst_B; // instance used in Lua code lua_State* L = lua_open(); luaL_openlibs(L); tolua_tclass_open(L); int top = lua_gettop(L); int loaderr = luaL_loadfile(L,"tclass.lua"); if (loaderr) { const char* errMsg = lua_tostring(L,-1); lua_settop(L,top); #ifdef _DEBUG ::printf_s("[LuaScriptModule]: %s\n", errMsg); #endif } // call it if (lua_pcall(L,0,0,0)) { const char* errMsg = lua_tostring(L,-1); lua_settop(L,top); #ifdef _DEBUG ::printf_s("[LuaScriptModule]: %s\n", errMsg); #endif } lua_settop(L,top); // just in case lua_close(L); delete b; return 0; }