@@ -12,7 +12,8 @@ The following is a minimal example of calling a foreign function which will
12
12
compile if snappy is installed:
13
13
14
14
~~~~ {.ignore}
15
- use std::libc::size_t;
15
+ extern crate libc;
16
+ use libc::size_t;
16
17
17
18
#[link(name = "snappy")]
18
19
extern {
@@ -44,7 +45,8 @@ keeping the binding correct at runtime.
44
45
The ` extern ` block can be extended to cover the entire snappy API:
45
46
46
47
~~~~ {.ignore}
47
- use std::libc::{c_int, size_t};
48
+ extern crate libc;
49
+ use libc::{c_int, size_t};
48
50
49
51
#[link(name = "snappy")]
50
52
extern {
@@ -402,7 +404,7 @@ global state. In order to access these variables, you declare them in `extern`
402
404
blocks with the ` static ` keyword:
403
405
404
406
~~~ {.ignore}
405
- use std:: libc;
407
+ extern crate libc;
406
408
407
409
#[link(name = "readline")]
408
410
extern {
@@ -420,7 +422,7 @@ interface. To do this, statics can be declared with `mut` so rust can mutate
420
422
them.
421
423
422
424
~~~ {.ignore}
423
- use std:: libc;
425
+ extern crate libc;
424
426
use std::ptr;
425
427
426
428
#[link(name = "readline")]
@@ -444,11 +446,15 @@ calling foreign functions. Some foreign functions, most notably the Windows API,
444
446
conventions. Rust provides a way to tell the compiler which convention to use:
445
447
446
448
~~~~
449
+ extern crate libc;
450
+
447
451
#[cfg(target_os = "win32", target_arch = "x86")]
448
452
#[link(name = "kernel32")]
449
453
extern "stdcall" {
450
- fn SetEnvironmentVariableA(n: *u8, v: *u8) -> std:: libc::c_int;
454
+ fn SetEnvironmentVariableA(n: *u8, v: *u8) -> libc::c_int;
451
455
}
456
+
457
+ # fn main() { }
452
458
~~~~
453
459
454
460
This applies to the entire ` extern ` block. The list of supported ABI constraints
0 commit comments