Skip to content

Commit 0f5ba54

Browse files
committed
Mention libc from crates.io in TRPL: FFI
Fixes #29762
1 parent 57c8a3e commit 0f5ba54

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/doc/trpl/ffi.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ foreign code. Rust is currently unable to call directly into a C++ library, but
88
snappy includes a C interface (documented in
99
[`snappy-c.h`](https://github.com/google/snappy/blob/master/snappy-c.h)).
1010

11+
## A note about libc
12+
13+
Many of these examples use [the `libc` crate][libc], which provides various
14+
type definitions for C types, among other things. If you’re trying these
15+
examples yourself, you’ll need to add `libc` to your `Cargo.toml`:
16+
17+
```toml
18+
[dependencies]
19+
libc = "0.2.0"
20+
```
21+
22+
[libc]: https://crates.io/crates/libc
23+
24+
and add `extern crate libc;` to your crate root.
25+
26+
## Calling foreign functions
27+
1128
The following is a minimal example of calling a foreign function which will
1229
compile if snappy is installed:
1330

0 commit comments

Comments
 (0)