简体   繁体   English

创建Lua状态时访问冲突

[英]Access Violation while creating Lua State

I have this simple program: 我有这个简单的程序:

#include <lua.hpp>

int main() {
    lua_State * ls = lua_newstate(0, 0);

    lua_close(ls);


    return 0;
}

I put the Lua DLL in the right folder, linked the libraries, setup the include folder, and compiled. 我把Lua DLL放在正确的文件夹中,链接库,设置include文件夹,然后编译。 It compiled cleanly, but when I run the program, it shows me this . 它编译得很干净,但是当我运行程序时,它会向我展示这一点 I'm using the latest version of LuaBinaries with Visual Studio 2017 我在Visual Studio 2017中使用了最新版本的LuaBinaries

You're giving the lua_newstate a null pointer as the allocator. 你给lua_newstate一个空指针作为分配器。 Naturally when it tries to allocate something there will be an access violation, as you saw. 当你试图分配某些内容时,当然会有违反访问权限的行为。

Why are you trying to call it this way? 你为什么试着这样称呼它? Maybe you want luaL_newstate() instead? 也许你想要luaL_newstate()而不是? It provides its own allocator system so you don't need to write your own. 它提供了自己的分配器系统,因此您无需编写自己的分配器系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM