README.md
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
52The following features are deprecated:
53
54* `use_std`: this is equivalent to `std`
55* `const-extern-fn`: this is now enabled by default
56* `align`: this is now enabled by default
57
58## Rust version support
59
60The minimum supported Rust toolchain version is currently **Rust 1.63**.
61
62Increases to the MSRV are allowed to change without a major (i.e. semver-
63breaking) release in order to avoid a ripple effect in the ecosystem. A policy
64for when this may change is a work in progress.
65
66`libc` may continue to compile with Rust versions older than the current MSRV
67but this is not guaranteed.
68
69## Platform support
70
71You can see the platform(target)-specific docs on [docs.rs], select a platform
72you want to see.
73
74See [`ci/verify-build.sh`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.sh) for
75the platforms on which `libc` is guaranteed to build for each Rust toolchain.
76The test-matrix at [GitHub Actions] and [Cirrus CI] show the platforms in which
77`libc` tests are run.
78
79<div class="platform_docs"></div>
80
81## License
82
83This project is licensed under either of
84
85* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
86 ([LICENSE-APACHE](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-APACHE))
87
88* [MIT License](https://opensource.org/licenses/MIT)
89 ([LICENSE-MIT](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-MIT))
90
91at your option.
92
93## Contributing
94
95We welcome all people who want to contribute. Please see the
96[contributing instructions] for more information.
97
98[contributing instructions]: https://github.com/rust-lang/libc/blob/HEAD/CONTRIBUTING.md
99
100Contributions in any form (issues, pull requests, etc.) to this project must
101adhere to Rust's [Code of Conduct].
102
103[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
104
105Unless you explicitly state otherwise, any contribution intentionally submitted
106for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be
107dual licensed as above, without any additional terms or conditions.
108
109[GitHub Actions]: https://github.com/rust-lang/libc/actions
110[GHA Status]: https://github.com/rust-lang/libc/workflows/CI/badge.svg
111[Cirrus CI]: https://cirrus-ci.com/github/rust-lang/libc
112[Cirrus CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg
113[crates.io]: https://crates.io/crates/libc
114[Latest Version]: https://img.shields.io/crates/v/libc.svg
115[Documentation]: https://docs.rs/libc/badge.svg
116[docs.rs]: https://docs.rs/libc
117[License]: https://img.shields.io/crates/l/libc.svg
118