Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose c_int as core::ffi::c_int? #3012

Closed
thomcc opened this issue Nov 4, 2020 · 6 comments
Closed

Expose c_int as core::ffi::c_int? #3012

thomcc opened this issue Nov 4, 2020 · 6 comments

Comments

@thomcc
Copy link
Member

thomcc commented Nov 4, 2020

This is already part of the target specification, and you can observe the size of c_int in no_std programs by examining the size of a #[repr(C)] enum.

If we're worried about future platforms with a Rust compiler and no C compiler, on such a platform it would just be a signed integer the same size as a #[repr(C)] enum.

@sfackler
Copy link
Member

sfackler commented Nov 4, 2020

The C standard does not mandate that enums be represented as an int:

Each enumerated type shall be compatible with char,asigned integer type, or an unsigned integer type. The choice of type is implementation-defined but shall be capable of representing the values of all the members of the enumeration.

@thomcc
Copy link
Member Author

thomcc commented Nov 4, 2020

Right, on targets with actual C compilers it should match (and in practice Rust currently uses the c_int size specified in the target spec for repr(C) enums, AFAICT anyway).

That's just a way forward for deciding the behavior on some hypothetical target that has no C compiler, and thus no c_int

@clarfonthey
Copy link
Contributor

There have been multiple requests to move the non-system-specific-but-still-target-specific stuff like c_int out of std and into core and alloc, and I definitely think there should be RFCs for them.

@joshtriplett
Copy link
Member

I would love to see most of the basic FFI types moved into core::ffi.

@rvolosatovs
Copy link

Tracking issue rust-lang/rust#94501

@petrochenkov
Copy link
Contributor

Closing in favor of the tracking issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants