Call WinAPI without an unsafe block

I was just starting to learn Rust and would like to know if it is possible to call WinAPI functions without danger.

extern crate libc;

fn main() {
    unsafe {
        libc::funcs::extra::kernel32::GetCurrentProcessId();
    }
}
+4
source share
1 answer

No, this is not possible because they are direct links to functions in C external libraries, like everything else in the box libc. This may not be obvious with functions such as GetCurrentProcessId(), but these functions are unsafe because there are many of them that take and return source pointers and null-terminated strings.

unsafe, , C. , . WinAPI, , . , .

+10

All Articles