Skip to content

Tracking Issue for #![feature(c_size_t)] (std::os::raw::c_size_t/std::os::raw::c_ssize_t) #88345

Open

Description

Feature gate: #![feature(c_size_t)].

This is a tracking issue for std::os::raw::{c_size_t, c_ssize_t}, which are guaranteed to be the same size as the underlying C size_t and ssize_t types from stddef.h.

Currently, on all targets, this is equivalent to usize and isize, however Rust has historically gone somewhat out of its way to avoid promising this. There are some targets with vaguely-planned support where this is not true (W65, used for SNES homebrew, for example)

Further reading here is available:

And probably more.

Public API

// std::os::raw

pub type c_size_t = usize;
pub type c_ssize_t = isize;

Steps / History

Unresolved Questions

  • Do we want to instead guarantee usize and size_t are the same? See https://internals.rust-lang.org/t/pre-rfc-usize-is-not-size-t/15369
  • Should this instead live in libcore somehow, given that probably libstd may never support platforms where this is not true. (This may not be true, since I imagine CHERI will support libstd)
  • Do we need both the signed and unsigned version, given that size_t is more common in function signatures.
  • ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: A tracking issue for an RFC or an unstable feature.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions