@@ -12,7 +12,8 @@ The following is a minimal example of calling a foreign function which will
1212compile if snappy is installed:
1313
1414~~~~ {.ignore}
15- use std::libc::size_t;
15+ extern crate libc;
16+ use libc::size_t;
1617
1718#[link(name = "snappy")]
1819extern {
@@ -44,7 +45,8 @@ keeping the binding correct at runtime.
4445The ` extern ` block can be extended to cover the entire snappy API:
4546
4647~~~~ {.ignore}
47- use std::libc::{c_int, size_t};
48+ extern crate libc;
49+ use libc::{c_int, size_t};
4850
4951#[link(name = "snappy")]
5052extern {
@@ -402,7 +404,7 @@ global state. In order to access these variables, you declare them in `extern`
402404blocks with the ` static ` keyword:
403405
404406~~~ {.ignore}
405- use std:: libc;
407+ extern crate libc;
406408
407409#[link(name = "readline")]
408410extern {
@@ -420,7 +422,7 @@ interface. To do this, statics can be declared with `mut` so rust can mutate
420422them.
421423
422424~~~ {.ignore}
423- use std:: libc;
425+ extern crate libc;
424426use std::ptr;
425427
426428#[link(name = "readline")]
@@ -444,11 +446,15 @@ calling foreign functions. Some foreign functions, most notably the Windows API,
444446conventions. Rust provides a way to tell the compiler which convention to use:
445447
446448~~~~
449+ extern crate libc;
450+
447451#[cfg(target_os = "win32", target_arch = "x86")]
448452#[link(name = "kernel32")]
449453extern "stdcall" {
450- fn SetEnvironmentVariableA(n: *u8, v: *u8) -> std:: libc::c_int;
454+ fn SetEnvironmentVariableA(n: *u8, v: *u8) -> libc::c_int;
451455}
456+
457+ # fn main() { }
452458~~~~
453459
454460This applies to the entire ` extern ` block. The list of supported ABI constraints
0 commit comments