#include <iostream>
using namespace std;
extern "C"{
#include <lua.hpp>
}
int main()
{
lua_State *L = luaL_newstate();
if(!L)
return -1;
luaL_dostring(
L,
"function add(first, second)\n"
" return first + second\n"
"end\n"
);
lua_close(L); /*Unhandled exception at 0x100042C0 (Lua.dll) in one more gain.exe: 0xC0000005: Access violation writing location 0x6D79F934.*/
cout << "Hello";
system("PAUSE");
return 0;
}
I've seen that sort of error before. I guess I'm accessing a null pointer? Yes the code gets past if(!L). Does anybody know what's going on?
EDIT: Screenshot added