Skip to content

Commit

Permalink
Improve comments and docs relating to char16_t.
Browse files Browse the repository at this point in the history
  • Loading branch information
adetaylor authored and emilio committed Feb 19, 2025
1 parent 61603fc commit 0df4256
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bindgen/codegen/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub(crate) mod ast_ty {
// argument is used. bindgen_cchar16_t is not a real type;
// but this allows downstream postprocessors to distinguish
// this case and do something special for C++ bindings
// containing char16_t.
// containing the C++ type char16_t.
IntKind::Char16 => syn::parse_quote! { bindgen_cchar16_t },
IntKind::SChar => raw_type(ctx, "c_schar"),
IntKind::UChar => raw_type(ctx, "c_uchar"),
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub enum IntKind {
/// A 16-bit integer, used only for enum size representation.
U16,

/// Either a `char16_t` or a `wchar_t`.
/// The C++ type `char16_t`, which is its own type (unlike in C).
Char16,

/// A 32-bit signed integer.
Expand Down
9 changes: 6 additions & 3 deletions bindgen/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,13 @@ macro_rules! options {
}

options! {
/// Whether we should distinguish between 'char16_t' and 'u16'.
/// As standard, bindgen represents `char16_t` as `u16`.
/// Whether we should distinguish between C++'s 'char16_t' and 'u16'.
/// The C++ type `char16_t` is its own special type; it's not a typedef
/// of some other integer (this differs from C).
/// As standard, bindgen represents C++ `char16_t` as `u16`.
/// Rust does not have a `std::os::raw::c_char16_t` type, and thus
/// we can't use a built-in Rust type in the generated bindings.
/// we can't use a built-in Rust type in the generated bindings (and
/// nor would it be appropriate as it's a C++-specific type.)
/// But for some uses of bindgen, especially when downstream
/// post-processing occurs, it's important to distinguish `char16_t`
/// from normal `uint16_t`. When this option is enabled, bindgen
Expand Down

0 comments on commit 0df4256

Please sign in to comment.