Use std::ffi::c_size_t doesn't work

I recently got a warning that feature core_ffi_c is stable. However, I still have problems with c_size_t:

#![feature(c_size_t)]

use core::ffi::c_size_t as _; // this works
use std::ffi::c_size_t as _; // this doesn't work

(Playground)

Is this going to be fixed eventually? (I'm often unsure whether to import things from core or std, by the way. I tend to use std everywhere but here it doesn't work.)

(Old thread on that matter when core_ffi_c was new)

Huh.

core_ffi_c is in fact on the train to stabilize in 1.64. c_size_t is still unstable... but lacks a reëxport into std. This is a bug.

If you're using std and not using #![no_std], it is fine, idiomatic, and expected to import everything from std. Every API item intended to be used by consumers is exported from std; for a no-no-std user, the fact std is split into crates is an implementation detail.

(In fact, there are vague plans (the "portability lint") of eventually making std:: usable for everyone, and just feature flagging functionality between targets.)

So yes, you should just use std::. (You know if you need to not.)

2 Likes