Skip to content

Commit

Permalink
Mention libc from crates.io in TRPL: FFI
Browse files Browse the repository at this point in the history
Fixes #29762
  • Loading branch information
steveklabnik committed Nov 17, 2015
1 parent 57c8a3e commit 0f5ba54
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/doc/trpl/ffi.md
Expand Up @@ -8,6 +8,23 @@ foreign code. Rust is currently unable to call directly into a C++ library, but
snappy includes a C interface (documented in
[`snappy-c.h`](https://github.com/google/snappy/blob/master/snappy-c.h)).

## A note about libc

Many of these examples use [the `libc` crate][libc], which provides various
type definitions for C types, among other things. If you’re trying these
examples yourself, you’ll need to add `libc` to your `Cargo.toml`:

```toml
[dependencies]
libc = "0.2.0"
```

[libc]: https://crates.io/crates/libc

and add `extern crate libc;` to your crate root.

## Calling foreign functions

The following is a minimal example of calling a foreign function which will
compile if snappy is installed:

Expand Down

0 comments on commit 0f5ba54

Please sign in to comment.