I've gone ahead and added the code to fail on bitfields, but I note that the original bug report referenced servo/rust-azure, which has the following
// FIXME: rust-bindgen can't handle bitfields [https://github.com/mozilla-servo/rust-azure/blob/master/azure-c.h#L235] So I'd still like to find a better way of handling this case. martin On Mon, Sep 9, 2013 at 11:47 AM, Martin DeMello <[email protected]> wrote: > That seems less than ideal - I mean, there are definitely c libraries > out there with bitfield widths in their header files, and we should be > able to use them from rust. And if we do, there should be a way to > generate the bindings that is systematic enough to be captured within > bindgen (possibly with a flag specifying the ABI). > > martin > > On Sun, Sep 8, 2013 at 7:37 PM, Corey Richardson <[email protected]> wrote: >> Emit an error and fail, I'd say, unless you can tell it which ABI it's >> targetting so it knows how to handle it. >> >> On Sun, Sep 8, 2013 at 8:20 PM, Martin DeMello <[email protected]> >> wrote: >>> On Sun, Sep 8, 2013 at 5:14 PM, Corey Richardson <[email protected]> wrote: >>>> On Sun, Sep 8, 2013 at 7:20 PM, Martin DeMello <[email protected]> >>>> wrote: >>>>> So am I right that bitfield widths would first need to be added to the >>>>> rust struct definition and code generator before they can be added to >>>>> bindgen? I poked around the AST and middle code a bit but couldn't >>>>> find it if it was there. >>>>> >>>> >>>> Rust doesn't have bitfields and neither does LLVM, nor do I think we >>>> should: >>>> >>>> 1. bitfield members aren't addressable. >>>> 2. It would be near impossible to replicate the exact behavior of >>>> every C compiler for every platform and ABI it supports. >>>> 3. They add significant additional complexity. >>> >>> Which returns me to the higher-level question, then - what is the >>> correct thing for bindgen to do if handed a C struct with them? >>> >>> martin _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
