Skip to content

Commit 3ea9eeb

Browse files
authored
Rollup merge of #94503 - joshtriplett:core-ffi-c, r=Amanieu
Provide C FFI types via core::ffi, not just in std Tracking issue: #94501 The ability to interoperate with C code via FFI is not limited to crates using std; this allows using these types without std. The existing types in `std::os::raw` become type aliases for the ones in `core::ffi`. This uses type aliases rather than re-exports, to allow the std types to remain stable while the core types are unstable. This also moves the currently unstable `NonZero_` variants and `c_size_t`/`c_ssize_t`/`c_ptrdiff_t` types to `core::ffi`, while leaving them unstable. Historically, we didn't do this because these types are target-dependent. However, `core` itself is also target-dependent. `core` should not call any OS services, but it knows the target and the target's ABI.
2 parents 1ff654a + 75c3e9c commit 3ea9eeb

File tree

23 files changed

+283
-168
lines changed

23 files changed

+283
-168
lines changed

library/std/src/os/raw/char.md renamed to library/core/src/ffi/c_char.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ Equivalent to C's `char` type.
22

33
[C's `char` type] is completely unlike [Rust's `char` type]; while Rust's type represents a unicode scalar value, C's `char` type is just an ordinary integer. On modern architectures this type will always be either [`i8`] or [`u8`], as they use byte-addresses memory with 8-bit bytes.
44

5-
C chars are most commonly used to make C strings. Unlike Rust, where the length of a string is included alongside the string, C strings mark the end of a string with the character `'\0'`. See [`CStr`] for more information.
5+
C chars are most commonly used to make C strings. Unlike Rust, where the length of a string is included alongside the string, C strings mark the end of a string with the character `'\0'`. See `CStr` for more information.
66

77
[C's `char` type]: https://en.wikipedia.org/wiki/C_data_types#Basic_types
88
[Rust's `char` type]: char
9-
[`CStr`]: crate::ffi::CStr
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)