1# libc - Raw FFI bindings to platforms' system libraries 2 3[![GHA Status]][GitHub Actions] [![Cirrus CI Status]][Cirrus CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License] 4 5`libc` provides all of the definitions necessary to easily interoperate with C 6code (or "C-like" code) on each of the platforms that Rust supports. This 7includes type definitions (e.g. `c_int`), constants (e.g. `EINVAL`) as well as 8function headers (e.g. `malloc`). 9 10This crate exports all underlying platform types, functions, and constants under 11the crate root, so all items are accessible as `libc::foo`. The types and values 12of all the exported APIs match the platform that libc is compiled for. 13 14Windows API bindings are not included in this crate. If you are looking for 15WinAPI bindings, consider using crates like [windows-sys]. 16 17More detailed information about the design of this library can be found in its 18[associated RFC][rfc]. 19 20[rfc]: https://github.com/rust-lang/rfcs/blob/HEAD/text/1291-promote-libc.md 21[windows-sys]: https://docs.rs/windows-sys 22 23## v1.0 Roadmap 24 25Currently, `libc` has two active branches: `main` for the upcoming v1.0 release, 26and `libc-0.2` for the currently published version. By default all pull requests 27should target `main`; once reviewed, they can be cherry picked to the `libc-0.2` 28branch if needed. 29 30We will stop making new v0.2 releases once v1.0 is released. 31 32See the section in [CONTRIBUTING.md](CONTRIBUTING.md#v10-roadmap) for more 33details. 34 35## Usage 36 37Add the following to your `Cargo.toml`: 38 39```toml 40[dependencies] 41libc = "0.2" 42``` 43 44## Features 45 46* `std`: by default `libc` links to the standard library. Disable this feature 47 to remove this dependency and be able to use `libc` in `#![no_std]` crates. 48 49* `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`. 50 This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`. 51 52* `const-extern-fn`: Changes some `extern fn`s into `const extern fn`s. If you 53 use Rust >= 1.62, this feature is implicitly enabled. Otherwise it requires a 54 nightly rustc. 55 56## Rust version support 57 58The minimum supported Rust toolchain version is currently **Rust 1.63**. 59 60Increases to the MSRV are allowed to change without a major (i.e. semver- 61breaking) release in order to avoid a ripple effect in the ecosystem. A policy 62for when this may change is a work in progress. 63 64`libc` may continue to compile with Rust versions older than the current MSRV 65but this is not guaranteed. 66 67## Platform support 68 69You can see the platform(target)-specific docs on [docs.rs], select a platform 70you want to see. 71 72See [`ci/build.sh`](https://github.com/rust-lang/libc/blob/HEAD/ci/build.sh) for 73the platforms on which `libc` is guaranteed to build for each Rust toolchain. 74The test-matrix at [GitHub Actions] and [Cirrus CI] show the platforms in which 75`libc` tests are run. 76 77<div class="platform_docs"></div> 78 79## License 80 81This project is licensed under either of 82 83* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) 84 ([LICENSE-APACHE](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-APACHE)) 85 86* [MIT License](https://opensource.org/licenses/MIT) 87 ([LICENSE-MIT](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-MIT)) 88 89at your option. 90 91## Contributing 92 93We welcome all people who want to contribute. Please see the 94[contributing instructions] for more information. 95 96[contributing instructions]: https://github.com/rust-lang/libc/blob/HEAD/CONTRIBUTING.md 97 98Contributions in any form (issues, pull requests, etc.) to this project must 99adhere to Rust's [Code of Conduct]. 100 101[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct 102 103Unless you explicitly state otherwise, any contribution intentionally submitted 104for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be 105dual licensed as above, without any additional terms or conditions. 106 107[GitHub Actions]: https://github.com/rust-lang/libc/actions 108[GHA Status]: https://github.com/rust-lang/libc/workflows/CI/badge.svg 109[Cirrus CI]: https://cirrus-ci.com/github/rust-lang/libc 110[Cirrus CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg 111[crates.io]: https://crates.io/crates/libc 112[Latest Version]: https://img.shields.io/crates/v/libc.svg 113[Documentation]: https://docs.rs/libc/badge.svg 114[docs.rs]: https://docs.rs/libc 115[License]: https://img.shields.io/crates/l/libc.svg 116