summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codegen/mod.rs16
-rw-r--r--src/ir/comp.rs2
2 files changed, 16 insertions, 2 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index ea9fec41..94a62b97 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1152,7 +1152,21 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
F: Extend<quote::Tokens>,
M: Extend<quote::Tokens>,
{
- let field_ty = helpers::blob(self.layout());
+ let field_ty = if parent.is_union() && !parent.can_be_rust_union(ctx) {
+ let ty = helpers::blob(self.layout());
+ if ctx.options().enable_cxx_namespaces {
+ quote! {
+ root::__BindgenUnionField<#ty>
+ }
+ } else {
+ quote! {
+ __BindgenUnionField<#ty>
+ }
+ }
+ } else {
+ helpers::blob(self.layout())
+ };
+
let unit_field_name = format!("_bitfield_{}", self.nth());
let unit_field_ident = ctx.rust_ident(&unit_field_name);
diff --git a/src/ir/comp.rs b/src/ir/comp.rs
index 230ba5b4..7320015f 100644
--- a/src/ir/comp.rs
+++ b/src/ir/comp.rs
@@ -1498,7 +1498,7 @@ impl CompInfo {
Field::DataMember(ref field_data) => {
field_data.ty().can_derive_copy(ctx)
}
- Field::Bitfields(_) => false,
+ Field::Bitfields(_) => true,
})
}
}