// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(repr_packed)] use std::mem; #[repr(packed)] struct P1 { a: T, b: u8, c: S } #[repr(packed(2))] struct P2 { a: T, b: u8, c: S } #[repr(C, packed(4))] struct P4C { a: T, b: u8, c: S } macro_rules! check { ($t:ty, $align:expr, $size:expr) => ({ assert_eq!(mem::align_of::<$t>(), $align); assert_eq!(mem::size_of::<$t>(), $size); }); } pub fn main() { check!(P1::, 1, 3); check!(P1::, 1, 11); check!(P2::, 1, 3); check!(P2::, 2, 12); check!(P4C::, 1, 3); check!(P4C::, 4, 12); }