From 0f5ba5459b8cf75be84ab9951de379a3f9d1f9d5 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 17 Nov 2015 11:12:57 -0500 Subject: [PATCH] Mention libc from crates.io in TRPL: FFI Fixes #29762 --- src/doc/trpl/ffi.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/doc/trpl/ffi.md b/src/doc/trpl/ffi.md index 7a58a327b9f95..d949bf33b6eea 100644 --- a/src/doc/trpl/ffi.md +++ b/src/doc/trpl/ffi.md @@ -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: