Skip to main content

luaur_compile_cli/functions/
assertion_handler.rs

1use core::ffi::{c_char, c_int, CStr};
2
3#[allow(non_snake_case)]
4pub fn assertion_handler(
5    expr: *const c_char,
6    file: *const c_char,
7    line: c_int,
8    _function: *const c_char,
9) -> c_int {
10    unsafe {
11        let file_str = CStr::from_ptr(file).to_string_lossy();
12        let expr_str = CStr::from_ptr(expr).to_string_lossy();
13
14        // Use standard Rust printing to stdout to avoid dependency on the libc crate,
15        // matching the behavior of the C++ printf call.
16        std::print!("{}({}): ASSERTION FAILED: {}\n", file_str, line, expr_str);
17    }
18    1
19}