rust-lang / rust-lang/rust-bindgen
Replacing native C types (Windows & Mac vs Linux)
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Rust
- Sterne
- 5.3k
- Forks
- 829
- Ø Merge
- 1 T. 1 Std.
- Gemergte PRs (30 T.)
- 15
Beschreibung
Bindgen nicely replaces occurrences of native C types with Rust types. For example:
#include <stdint.h>
typedef struct
{
const uint8_t b[16];
} MunGuid;
results in:
#[repr(C)]
#[derive(Clone, Copy)]
pub struct Guid {
pub b: [u8; 16usize],
}
It works. Lovely! One problem, once we run CI, it turns out that Ubuntu also generates this additional line
pub type __uint8_t = ::std::os::raw::c_uchar;
Even though bindgen is able to deduce that uint8_t is supposed to be u8, it still adds the __uint8_t type to the generated bindings.
One possible solution that I came up with to resolved this is to blacklist the __uint8_t type, but then bindgen stops automatically generating the #[derive(Clone, Copy)] attributes.
Is there a way to prevent the generation of "replaced" types?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere die generierten Bindings aus dem C-Beispiel des Issues unter Ubuntu und vergleiche sie mit der Ausgabe unter Windows oder macOS. Verfolge zunächst, wie bindgen native typedefs und Ersetzungstypen behandelt; abgeschlossen ist die Aufgabe, wenn redundante Deklarationen ersetzter Typen verhindert werden, ohne die generierten derives zu verlieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, rust
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100