tools: add a static size assertion

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-08-23 11:26:57 +02:00
parent e1ebf9b67e
commit f1351e7e41

View File

@ -19,6 +19,16 @@ macro_rules! offsetof {
};
}
/// Static assertions
#[macro_export]
macro_rules! static_assert_size {
($ty:ty, $size:expr) => {
const _: fn() -> () = || {
let _ = ::std::mem::transmute::<[u8; $size], $ty>;
};
};
}
/// Macro to write error-handling blocks (like perl eval {})
///
/// #### Example: