C_size_t disappeared. Where did it go?

It still exists in the docs: std::os::raw::c_size_t. But apparently it's no longer available?

#![feature(c_size_t)]
use std::os::raw::c_size_t;

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error[E0432]: unresolved import `std::os::raw::c_size_t`
 --> src/lib.rs:3:5
  |
3 | use std::os::raw::c_size_t;
  |     ^^^^^^^^^^^^^^^^^^^^^^ no `c_size_t` in `os::raw`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `playground` due to previous error

Nightly channel
Build using the Nightly version: 1.61.0-nightly
(2022-03-18 1bfe40d11c3630254504)

As my code compiled previously, I assume I didn't just make a stupid copy&paste error. Or what's wrong here?

The docs you linked are from the current stable release (despite it documenting an unstable type) - the nightly std::os::raw docs are here, and the type is indeed missing there.

It looks like all of the C FFI types moved into core::ffi earlier this month, and only the stable ones are currently being re-exported:

So you'll need to import c_size_t from core::ffi instead, I think?

2 Likes

Yep:

-use std::os::raw::c_size_t;
+use core::ffi::c_size_t;

Thanks for the quick help. On playground it works. On my local machine (rustc 1.61.0-nightly (1bfe40d11 2022-03-18)) on FreeBSD it fails. I needed to add #![feature(core_ffi_c)] as well to avoid this:

error[E0658]: use of unstable library feature 'core_ffi_c'
  --> src/common.rs:11:16
   |
11 | use std::ffi::{c_int, c_size_t, c_void, CString};
   |                ^^^^^
   |
   = note: see issue #94501 <https://github.com/rust-lang/rust/issues/94501> for more information
   = help: add `#![feature(core_ffi_c)]` to the crate attributes to enable

Not sure why this problem doesn't exist on playground.

It does. c_int is part of a different feature.

1 Like

Ooops, okay, thanks, and sorry for my confusion.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.