Skip to content

Commit e760740

Browse files
authored
Rollup merge of #88340 - thomcc:c_size_t, r=joshtriplett
Add `c_size_t` and `c_ssize_t` to `std::os::raw`. Apparently these aren't guaranteed to be the same, and are merely "always the same in practice" (see https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/.60usize.60.20vs.20.60size_t.60). This is a big footgun, but I suspect it can be alleviated if we expose this and start migrating people to it in advance of any platforms that ever have this as different. I'll file a tracking issue after this gets some traction.
2 parents 0f7dc5d + 5b25de5 commit e760740

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

library/std/src/os/raw/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,17 @@ type_alias_no_nz! { "double.md", c_double = f64; }
151151
#[stable(feature = "raw_os", since = "1.1.0")]
152152
#[doc(no_inline)]
153153
pub use core::ffi::c_void;
154+
155+
/// Equivalent to C's `size_t` type, from `stddef.h` (or `cstddef` for C++).
156+
///
157+
/// This type is currently always [`usize`], however in the future there may be
158+
/// platforms where this is not the case.
159+
#[unstable(feature = "c_size_t", issue = "88345")]
160+
pub type c_size_t = usize;
161+
162+
/// Equivalent to C's `ssize_t` type, from `stddef.h` (or `cstddef` for C++).
163+
///
164+
/// This type is currently always [`isize`], however in the future there may be
165+
/// platforms where this is not the case.
166+
#[unstable(feature = "c_size_t", issue = "88345")]
167+
pub type c_ssize_t = isize;

0 commit comments

Comments
 (0)