简体   繁体   中英

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. 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

You're giving the lua_newstate a null pointer as the allocator. 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? It provides its own allocator system so you don't need to write your own.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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