rust/src/test/run-pass/bind-native-fn.rs
Graham Fawcett 7ddd353ef6 implement #[nolink]; deprecate #[link_name = ""]; note in stdlib to remove empty link_name.
Can't remove them from stdlib until the snapshotted compiler supports #[nolink].
2011-12-16 15:29:59 -08:00

22 lines
421 B
Rust

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