我正在将 LUA 用于 SDL 项目。我从这里 (http://sourceforge.net/projects/luabinaries/files/5.2/Windows%20Libraries/Dynamic/) (lua-5.2_Win32_dll10_lib.zip) 下载了预编译的 LIB 和 DLL 文件,并将其合并到我的项目中。当我构建调试版本时,应用程序运行 100% 正常。当我将它设置为 Release模式并按下 Visual Studio 中的播放按钮时,它也运行良好。
但是,如果我通过在文件夹中双击运行 Release 文件,我会收到带有 lua52.dll 的错误 c0000005。
我正在运行 MicroSoft Visual C++ 2010 Express。
我经历了删除行直到它开始工作,导致错误的行是。
void aiBrainmanager::run(string holdData){
int errfunc = 0;
int s;
int s = luaL_loadstring(L, holdData.c_str());
if ( s==0 ) {
s = lua_pcall(L, 0, LUA_MULTRET, errfunc);
}
if (errfunc !=0) {
}
if (s !=0) {
aiBrainmanager::target->stopWorking();
}
}
知道什么设置有问题或如何解决。
最佳答案
0xc0000005 是内存违规。它在调试中工作的事实意味着许多可能的事情。
- 内存未被初始化或设置正确(在调试中它被初始化为 0)因此字符串被终止,例如。
- 内存要求大于缓冲区允许的范围(在调试中可以填充)。
- 你的代码在调试中做的事情与编译时不同(#if 等)
查看您的代码我会查看:
为什么你检查错误然后什么都不做?????
if (errfunc !=0) {
// What happens in here??????
}
The lua_pcall function returns 0 in case of success or one of the following error codes (defined in lua.h):
LUA_ERRRUN: a runtime error.
LUA_ERRMEM: memory allocation error. For such errors, Lua does not call the error handler function.
LUA_ERRERR: error while running the error handler function
我想你会发现你得到了一个LUA_ERRMEM
关于c++ - 当我为调试 Lua 编译我的程序时运行良好,但为什么我为发布编译它我得到一个 c0000005 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10051614/