ziglua
ziglua copied to clipboard
Define apicheck function to use a Zig panic
From a quick glance at the Lua sources, it may be possible to override the use of assert.h for the API check with a custom function. If so, this would make api checks much more easy to debug with zig panics and stack traces.
this is doable from consumer code:
pub fn main() void {
// ...
var act: std.posix.Sigaction = .{
.handler = .{ .handler = handleAbrt },
.mask = switch (builtin.os.tag) {
.macos => 0,
.linux => std.posix.empty_sigset,
else => @compileError("os not supported"),
},
.flags = 0,
};
std.posix.sigaction(std.posix.SIG.ABRT, &act, null) catch {}; // if it doesn't work, we just crash the old way lol
// ...
}
fn handleAbrt(_: c_int) callconv(.C) noreturn {
@call(.always_inline, std.debug.panic, .{ "assertion failed!!", .{} });
}