rust/src/test/run-pass/bind-native-fn.rs
2012-04-08 23:14:57 +08:00

22 lines
402 B
Rust

// From #1174:
// xfail-fast
use std;
import str;
import libc::*;
#[nolink]
native mod libc {
fn write(fd: core::libc::c_int, buf: *u8, nbyte: core::libc::size_t);
}
fn main() {
let s = "hello world\n";
let b = str::bytes(s);
let l = str::len(s);
let b8 = unsafe { vec::unsafe::to_ptr(b) };
libc::write(0i32, b8, l);
let a = bind libc::write(0i32, _, _);
a(b8, l);
}