Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Hide differencesHistory of post edits

#ActualShaquil

Posted 02 November 2012 - 10:19 AM

After a bit of a struggle, I've gotten Lua to work with Visual Studio 2012 (Lua 5.2). Unfortunately, now, when I run some simple test code, it crashes at runtime with an unhandled exception, but only when I call lua_close(). Here's the code:

#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

After a bit of a struggle, I've gotten Lua to work with [b]Visual Studio 2012 (Lua 5.2)[/b]. Unfortunately, now, when I run some simple test code, it crashes at runtime with an unhandled exception, but only when I call lua_close(). Here's the code:

[CODE]
#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;
}
[/CODE]

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

#1Shaquil

Posted 02 November 2012 - 10:10 AM

After a bit of a struggle, I've gotten Lua to work with Visual Studio 2012 (Lua 5.2). Unfortunately, now, when I run some simple test code, it crashes at runtime with an unhandled exception, but only when I call lua_close(). Here's the code:

#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?

PARTNERS

Warning: include_once(RContent/redis.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/gamedev/admin/applications_addon/ips/ccs/sources/pages.php(458) : eval()'d code on line 20642

Warning: include_once() [function.include]: Failed opening 'RContent/redis.php' for inclusion (include_path='/var/www/gamedev/ips_kernel/PEAR/') in /var/www/gamedev/admin/applications_addon/ips/ccs/sources/pages.php(458) : eval()'d code on line 20642