Open HadrienG2 opened 4 months ago
My first impression is that this is a good idea. My main thoughts on the subject are:
TLDR: Sounds like a desirable thing, just needs someone implementing so we can figure out small details that might come up.
There might be name collisions if two structs have fields with the same name. So that means that we cannot drop the number suffix at the end in all cases.
Sorry, I did not understand this part. Can this really happen if the type name contains the name of the struct as a prefix, as in my proposal? In my mind, if hwloc_bridge_attr_s::upstream
is a unique entity in C (and it should be), then there is no reason why a matching autogenerated hwloc_bridge_attr_s__upstream
Rust type name shouldn't be unique.
Okay, technically, a C library could have another type using the same naming convention (literally a struct hwloc_bridge_attr_s__upstream {};
), but who does that? ;)
While they have a good chance of avoiding namespace collisions, numbered anonymous types are decidedly not very readable.
It would be nice if bindgen could use the field name instead when naming the anonymous type. In the above example,
hwloc_bridge_attr_s__bindgen_ty_1
would becomehwloc_bridge_attr_s__upstream
andhwloc_bridge_attr_s__bindgen_ty_2
would becomehwloc_bridge_attr_s__downstream
.