diff options
author | Christian Legnitto <christian@legnitto.com> | 2019-01-07 20:06:34 -0800 |
---|---|---|
committer | Christian Legnitto <christian@legnitto.com> | 2019-01-08 08:56:19 -0800 |
commit | 3994a9a3a75245fcec59a2a3e62f163c1fa2e24b (patch) | |
tree | ba331e1ce2f9216896394783085003da86526ea8 /src/codegen/mod.rs | |
parent | 28c0eb4505865220d6f2a8f779f5876dc753feac (diff) |
Support #[repr(packed(N))] on Rust 1.33+
Fixes https://github.com/rust-lang/rust-bindgen/issues/537.
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r-- | src/codegen/mod.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 6fd7e7d3..d3395edf 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1673,7 +1673,10 @@ impl CodeGenerator for CompInfo { attributes.push(attributes::doc(comment)); } if packed && !is_opaque { - attributes.push(attributes::repr_list(&["C", "packed"])); + let n = layout.map_or(1, |l| l.align); + assert!(ctx.options().rust_features().repr_packed_n || n == 1); + let packed_repr = if n == 1 { "packed".to_string() } else { format!("packed({})", n) }; + attributes.push(attributes::repr_list(&["C", &packed_repr])); } else { attributes.push(attributes::repr("C")); } |