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

Distinguish char16_t. #3135

Merged
merged 1 commit into from
Feb 16, 2025
Merged

Distinguish char16_t. #3135

merged 1 commit into from
Feb 16, 2025

Conversation

adetaylor
Copy link
Contributor

With a new command-line option, this ensures that char16_t is distinct from uint16_t in generated bindings. On some platforms these are distinct types, so it can be important for downstream post processors to spot the difference.

See the documentation on the new command-line option for expected behavior and usage here.

Part of google/autocxx#124.

With a new command-line option, this ensures that char16_t
is distinct from uint16_t in generated bindings. On some platforms
these are distinct types, so it can be important for downstream
post processors to spot the difference.

See the documentation on the new command-line option for
expected behavior and usage here.

Part of google/autocxx#124.
Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of adding bindgen-specific types that users are supposed to replace, but lacking something better this seems reasonable... Maybe worth an upstream issue to add char16_t to core::ffi and co? If you think it's a good idea adding a link to the code in a follow-up would be appreciated :)

@emilio emilio added this pull request to the merge queue Feb 16, 2025
Merged via the queue into rust-lang:main with commit a10bcfd Feb 16, 2025
34 checks passed
@adetaylor
Copy link
Contributor Author

Not a huge fan of adding bindgen-specific types that users are supposed to replace, but lacking something better this seems reasonable... Maybe worth an upstream issue to add char16_t to core::ffi and co? If you think it's a good idea adding a link to the code in a follow-up would be appreciated :)

Thanks for merging despite your concerns.

I think unfortunately the mess here runs deep. std::os::raw seems to lack quite a few of the integer types defined in C's stdint. char16_t is in fact uint_least16_t. But only in C! In C++, char16_t appears to be a different type again. (I only just figured this out) - "It has the same size, signedness, and alignment as std::uint_least16_t, but is a distinct type.".

Given that, it actually doesn't make any sense to add C++'s char16_t into std::os::raw, because it's not a C type, only C++.

But I think some of my comments in the previous PR need to be modified to explain that we're talking about C++'s char16_t not C's char16_t. I'll send a follow up PR...

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

Successfully merging this pull request may close these issues.

2 participants