Open ahaoboy opened 7 months ago
Ideally these would just import from libc
directly:
// b.c
use ::libc::printf;
#[no_mangle]
pub unsafe extern "C" fn funB(mut n: libc::c_int) -> libc::c_int {
printf(b"funB\0" as *const u8 as *const libc::c_char);
return n;
}
// a.rs
use ::libc::{printf, puts};
#[no_mangle]
pub unsafe extern "C" fn funA(mut n: libc::c_int) -> libc::c_int {
puts(b"funA\0" as *const u8 as *const libc::c_char);
printf(b"funA\0" as *const u8 as *const libc::c_char);
return n;
}
Currently, libc functions are individually imported in each file. If there is a need to replace a particular function, modifications are required in all files using it. Consolidating all libc functions into one file would require modifications only in that file for any changes.