Re: [PATCH v5 01/10] doc: define unambiguous type mappings across C and Rust
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 19, 2025, 04:14 UTC
- Message-ID
- <87h5uqk69w.fsf@gitster.g>
- In-Reply-To
- <9c7a7d09-2cc0-40f7-b37a-befef5339d76@ramsayjones.plus.com>
Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
Show 20 quoted lines
>> +== Character types >> + >> +This is where C and Rust don't have a clean one-to-one mapping. >> + >> +A C `char` and a Rust `u8` share the same bit width, so any C struct containing >> +a `char` will have the same size as the corresponding Rust struct using `u8`. >> +In that sense, such structs are safe to pass over the FFI boundary, because >> +their fields will be laid out identically. However, beyond bit width, C `char` >> +has additional semantics and platform-dependent behavior that can cause >> +problems, as discussed below. >> + >> +The C language leaves the signedness of `char` implementation defined. Because >> +our developer build enables -Wsign-compare, comparison of a value of `char` >> +type with either signed or unsigned integers may trigger warnings from the >> +compiler. > > Yep, much better. Thanks! > > ATB, > Ramsay Jones
Indeed. Thanks, both.