问题描述
"luaL_dofile"行中的错误,调试器未显示任何有关错误的信息.
Error at line "luaL_dofile" and debugger doesn't show anything about error.
我可以使用命令"luaL_dostring",但是我不知道为什么不能归档.
I can use command "luaL_dostring" but I don't know why I can't dofile.
我的代码如下:
const char* file = "/app_home/data/minigames/mg_hint_machine_2.lua";
ret = luaL_dofile(LS, file);
if(ret != 0){
PRINTF("Error occurs when calling luaL_dofile() Hint Machine 0x%x\n",ret);
}
else PRINT("\nDOFILE SUCCESS");
并且调试器在此行中显示错误,并且"ret"仍然无法从dofile中获得返回值.
and debugger shows error in this line and "ret" still not get returned value from dofile.
如果您想了解调试器中的错误
If you want to see about error in debugger
02C2D304 7C21016A stdux r1,r1,r0 03(02C2D300)REG PIPE LSU
调试器指向这一行,我听不懂.
Debugger points in this line and I can't understand it.
推荐答案
详细说明一下superzilla的答案(支持该答案而不是这个答案),要获取错误消息,您的代码需要如下所示:
As an elaboration on superzilla's answer (upvote that answer rather than this one),to get the error message your code needs to look like this:
const char* file = "/app_home/data/minigames/mg_hint_machine_2.lua";
ret = luaL_dofile(LS, file);
if(ret != 0){
PRINTF("Error occurs when calling luaL_dofile() Hint Machine 0x%x\n",ret);
PRINTF("Error: %s", lua_tostring(LS,-1));
}
else PRINT("\nDOFILE SUCCESS");
您的更改(在注释中)将luaL_dofile
更改为luaL_dostring
,这就是为什么您收到意外错误消息的原因(如).
Your change (in the comments) changed the luaL_dofile
to a luaL_dostring
, which is why you're getting unexpected error message ( as mentioned here ).
这篇关于luaL_dofile错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!