Skip to content

Commit 8e7abea

Browse files
committed
revert libc changes
1 parent 54ecc21 commit 8e7abea

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/doc/book/ffi.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,12 @@ global state. In order to access these variables, you declare them in `extern`
461461
blocks with the `static` keyword:
462462

463463
```rust,no_run
464-
use std::os::raw::c_int;
464+
# #![feature(libc)]
465+
extern crate libc;
465466
466467
#[link(name = "readline")]
467468
extern {
468-
static rl_readline_version: c_int;
469+
static rl_readline_version: libc::c_int;
469470
}
470471
471472
fn main() {
@@ -479,14 +480,15 @@ interface. To do this, statics can be declared with `mut` so we can mutate
479480
them.
480481

481482
```rust,no_run
483+
# #![feature(libc)]
484+
extern crate libc;
482485
483486
use std::ffi::CString;
484-
use std::os::raw::c_char;
485487
use std::ptr;
486488
487489
#[link(name = "readline")]
488490
extern {
489-
static mut rl_prompt: *const c_char;
491+
static mut rl_prompt: *const libc::c_char;
490492
}
491493
492494
fn main() {
@@ -511,13 +513,14 @@ calling foreign functions. Some foreign functions, most notably the Windows API,
511513
conventions. Rust provides a way to tell the compiler which convention to use:
512514

513515
```rust
514-
use std::os::raw::c_int;
516+
# #![feature(libc)]
517+
extern crate libc;
515518

516519
#[cfg(all(target_os = "win32", target_arch = "x86"))]
517520
#[link(name = "kernel32")]
518521
#[allow(non_snake_case)]
519522
extern "stdcall" {
520-
fn SetEnvironmentVariableA(n: *const u8, v: *const u8) -> c_int;
523+
fn SetEnvironmentVariableA(n: *const u8, v: *const u8) -> libc::c_int;
521524
}
522525
# fn main() { }
523526
```
@@ -690,11 +693,12 @@ void bar(void *arg);
690693
We can represent this in Rust with the `c_void` type:
691694
692695
```rust
693-
use std::os::raw::c_void;
696+
# #![feature(libc)]
697+
extern crate libc;
694698
695699
extern "C" {
696-
pub fn foo(arg: *mut c_void);
697-
pub fn bar(arg: *mut c_void);
700+
pub fn foo(arg: *mut libc::c_void);
701+
pub fn bar(arg: *mut libc::c_void);
698702
}
699703
# fn main() {}
700704
```

0 commit comments

Comments
 (0)