-
Notifications
You must be signed in to change notification settings - Fork 327
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
Is it possible to map usize to size_t and isize to ptrdiff_t? #239
Comments
Why do you want this? Changing usize to size_t would be incorrect and might break on certain platforms. |
Which platforms exactly? IIRC |
You might want to check answers to same question previously asked in #198. Rust's |
The way we use usize to hold I'm not even sure rust itself supports architectures with Given that intptr_t is optional and makes C people complain because looks weird to them, I'd rather map it to size_t as long the two are compatible, thus why I'd rather have a way to annotate the type so it maps to what the user expects (size_t for array lengths and ptrdiff_t for strides). The defaults can stay as they are :) |
I think it does, it just doesn't have equivalent of
That sounds like a strange personal preference, not something to base choice of type representation on, especially because
is not actually guaranteed at all and causes user to rely on UB, which can go really wrong. |
My problem is getting the users what they expect, I have no problems in adding a build/configure time checks to make sure the incompatible platforms are managed and then use the right type and then annotate it so it is expressed as they want. |
To expand, I'd be glad to have |
Actually |
Yes, the preferred solution here would be for the rust side to use the native types that C/C++ expect. As @RReverser notes, usize and isize are not equivalent to size_t or ptrdiff_t. Adding a configuration option here would be too big of a footgun and maintenance burden in my opinion. |
I merged PR #242 to resolve this. |
I'm not sure if there is a mean to annotate to do this mapping.
The text was updated successfully, but these errors were encountered: