Skip to main content

luaur_analyze_cli/functions/
assertion_handler.rs

1#[no_mangle]
2pub unsafe extern "C" fn assertion_handler(
3    expr: *const core::ffi::c_char,
4    file: *const core::ffi::c_char,
5    line: core::ffi::c_int,
6    _function: *const core::ffi::c_char,
7) -> core::ffi::c_int {
8    let file_str = unsafe { core::ffi::CStr::from_ptr(file) }.to_string_lossy();
9    let expr_str = unsafe { core::ffi::CStr::from_ptr(expr) }.to_string_lossy();
10    // Using libc printf equivalent via std::io::Write to stdout
11    use std::io::Write;
12    let _ = write!(
13        std::io::stdout(),
14        "{}({}): ASSERTION FAILED: {}\n",
15        file_str,
16        line,
17        expr_str
18    );
19    let _ = std::io::stdout().flush();
20    1
21}