-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Types in std::os::raw should be same as libc crate #47027
Comments
I feel like this issue is a duplicate, but I'm not sure. |
It was definitely listed in the original libc RFC as an unresolved question, and I found #36193, but I really didn't find anything that addressed this specific issue. There are also issues regarding |
New RFC to propose fixing for Unlike Are there cases where |
IMO, the fact that the code disagrees is an indication that that's probably the case. Regardless, I feel that the code for these should be the same, whether this is done by re-exporting or simply copying the code. |
To make sure the definitions never diverge I think it would be best to have them in one place, and re-export as needed. So let’s keep this issue open even if rust-lang/rfcs#2521 is implemented. |
I noticed that c_char is u8 in std vs i8 in libc yesterday |
On what target architecture? This doesn’t seem to be the case on Linux x64 at least: |
A big example of a difference is |
Seemingly I was wrong... I was reading through the sources and apparently mixed up the |
Also I seem not the odd one one out here https://users.rust-lang.org/t/crate-types-not-the-same-which-one-should-i-use/19552 |
Genuine question: would it make sense to maybe make all of the This way, although they'll work in FFI as expected, Rust code has to use We could even do this with the inner implementation of |
We can add new types like that. But changing the existing |
I think that adding new types is reasonable, if they go into |
These new types wouldn’t solve this issue’s problem (so they are not quite on topic), and I feel there would be enough details to figure out that they’d be worth their own RFC. |
Tracking issue here in case you want to provide input: #94501 |
libc currently does rustc version detection, so libc could turn these into re-exports when built on a sufficiently new rustc. |
Do the definitions agree for all targets? As long as they do there’s no effect for users, for type aliases to primitive integers (as opposed to |
Was going through my open issues and was wondering whether this is solved or not. The linked #94501 is merged, and I believe that the types do match now. Should this still be tracked in the standard library, or just as an issue in the libc repo? |
@joshtriplett What's the current status for this issue? |
Right now, there's a bit of a discrepancy between these two, even though there shouldn't be. While the libc crate has very complicated logic to determine how the
c_*
types are defined, the standard library uses a much simpler logic.I'm not sure how much these types are desired outside of libc; the only type that I've really seen used across the standard library is
c_char
, which honestly could just be replaced with an opaque struct withrepr(u8)
if it weren't already stabilised.The text was updated successfully, but these errors were encountered: