mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-28 11:13:36 +00:00
tools: add a static size assertion
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
e1ebf9b67e
commit
f1351e7e41
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user