Is there any way that I can, in a C++ function, return a pointer to a class to lua? I have tried this, among other more desperate things:
P* GetP()
{
return g_P;
}
module(L)
[
def("GetP", &GetP)
]
This makes the program crash even before running the first line in main(), even if the code just sits in a function that is never called.
I thought it was a problem that P was unknown to luabind, but even telling it what it was failed.
module(L)
[
class_<P>("ClassP")
.def(constructor<>())
]
This could be because P have a somewhat complex inheritance hierarchy, not sure.
class GO;
class L;
class C : public GO;
class P : public C, L;
I have tried different approaches to tell luabind of the inheritance of P, none gave any result.
The crash I get is a Unhandled exception at 0x0059a064 in program.exe: 0xC0000005: Access violation reading location 0x00000004, found in xtree.
_Pairib insert(const value_type& _Val)
{ // try to insert node with value _Val
_Nodeptr _Trynode = _Root();
_Nodeptr _Wherenode = _Myhead;
bool _Addleft = true; // add to left of head if tree empty
Any help appreciated.