[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LuaJIT and C++ exception
- From: Andrea <mariofutire@...>
- Date: Fri, 15 Oct 2010 22:20:56 +0100
Hi,
I'm going back to the common topic of C++ exceptions.
I'm using VS 2005 x86.
Basically I register a C++ function with lua_pushcclosure.
This function does not throw, since it contains a try catch like the one suggested here
http://luajit.org/api.html
What happens is the following
pcall
from lua call c closure
throw something
catch (...)
lua_pushstring
lua_error
....
.... back into lua
....
back in pcall which returns a non zero value
and I then throw a new C++ exception (caught higher in the stack in my app).
The problem is that Visual Studio reports that the 2nd exception is unhandled and basically ignores it.
This works fine with Lua (non jit).
The only way to make it work with lua jit is to ensure that the function calling lua_error does not
contain any try{}catch{} block.
It must be handled by an other function which can signal success or error via standard c methods
(e.g. the return code).
As soon as lua_error is in a function that contains try{}catch{} it fails. Mind you, lua_error is
*outside* the try{}catch{}, *not* in the catch, but still in the same function (like the link above).
Havent tried in linux yet.
Am I talking nonsense?
Andrea