davidsiaw / luacppinterface

A Simple C++ Interface to Lua
MIT License
168 stars 28 forks source link

Access violation when accessing string #26

Closed yiochen closed 8 years ago

yiochen commented 8 years ago

I tried to run Demostration4.cpp where you read in a file and try to access a string defined in the lua file. Visual Studio 2015 reports Access Violation on that. This is the call stack

>   LuaCppTest.exe!std::char_traits<char>::length(const char * _First) Line 523 C++
    LuaCppTest.exe!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::assign(const char * _Ptr) Line 1176    C++
    LuaCppTest.exe!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >(const char * _Ptr) Line 827    C++
    LuaCppTest.exe!popper<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >::pop(std::shared_ptr<lua_State> state) Line 128    C++
    LuaCppTest.exe!LuaTable::Get<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >(std::basic_string<char,std::char_traits<char>,std::allocator<char> > key) Line 53   C++
    LuaCppTest.exe!main() Line 15   C++
    [External Code] 
    [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]  

Anyone knows how to solve it?

yiochen commented 8 years ago

Nevermind. I found out why. The problem was that Visual studio doesn't know where to look for the config.lua file. So the code failed to read the file. Moving config.lua to the root directory of the LuaCppTest project solved the problem for me. I am sorry.