Original Post
Hello ppl. I have just downloaded and builded luabind beta 6 in VS.NET2003. There was some errors abound the apply_if that was corrected by changing them to eval_if. But, when I test the lib to see if everything is fine, it just craches when I try to use classes. Can anyone tell me what is going on? here it is the test code that craches:
#include <string>
#include <iostream>
using namespace std;
extern "C"{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}
#include <luabind/luabind.hpp>
using namespace luabind;
#pragma comment(lib, "lualib.lib")
#pragma comment(lib, "luabind.lib")
string GetCommand(){
char s[513];
cin.getline(s, 512);
return s;
}
string Escrever(int a){
cout<<"Funcao ligada a lua atravez do luabind "<<a<<endl;
return "Funcao ligada a lua atravez do luabind\n";
}
class testclass
{
public:
testclass(const std::string& s): m_string(s) {}
void print_string() { std::cout << m_string << "\n"; }
private:
std::string m_string;
};
int main(){
lua_State* vm = lua_open();
lua_baselibopen(vm);
lua_iolibopen(vm);
lua_strlibopen(vm);
lua_mathlibopen(vm);
function(vm, "Escrever", &Escrever);
class_<Vector>(vm, "testclass").def(constructor<>());
do{
cout<<" > ";
string command = GetCommand();
lua_dostring(vm, command.c_str());
}while(true);
lua_close(vm);
return 0;
}
and it craches here: "Unhandled exception at 0x0041ec97 in LuaBindTest.exe: 0xC0000005: Access violation reading location 0x00000010." class_rep.cpp : ln 88