Unsafe block and order call function


#1

I have custom lib.

#[link(name="mylib")]
     extern {
        fn from_mylib();
     }

fn main() {
     println!("try call...");

    unsafe {
       from_mylib();
    }

    println!("\n");   // this must call after unsafe block
}

compile and run

$./main 
try call...

hello from My Lib!

Why second println! called ALWAYS before unsafe block

Rust version

$ rustc --version
rustc 1.0.0-beta

#2

Does from_mylib() print with a newline at the end? stdout is line buffered and will only be automatically flushed to screen when a newline is printed. You can also flush it manually.