]> git.lizzy.rs Git - rust.git/blob - library/core/src/ffi/c_void.md
Rollup merge of #106414 - cuviper:libs-review, r=Mark-Simulacrum
[rust.git] / library / core / src / ffi / c_void.md
1 Equivalent to C's `void` type when used as a [pointer].
2
3 In essence, `*const c_void` is equivalent to C's `const void*`
4 and `*mut c_void` is equivalent to C's `void*`. That said, this is
5 *not* the same as C's `void` return type, which is Rust's `()` type.
6
7 To model pointers to opaque types in FFI, until `extern type` is
8 stabilized, it is recommended to use a newtype wrapper around an empty
9 byte array. See the [Nomicon] for details.
10
11 One could use `std::os::raw::c_void` if they want to support old Rust
12 compiler down to 1.1.0. After Rust 1.30.0, it was re-exported by
13 this definition. For more information, please read [RFC 2521].
14
15 [Nomicon]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
16 [RFC 2521]: https://github.com/rust-lang/rfcs/blob/master/text/2521-c_void-reunification.md