diff --git a/proxmox-tools/src/lib.rs b/proxmox-tools/src/lib.rs index 8e3c93d8..1d3cc27b 100644 --- a/proxmox-tools/src/lib.rs +++ b/proxmox-tools/src/lib.rs @@ -2,3 +2,11 @@ pub mod io; pub mod vec; + +/// Evaluates to the offset (in bytes) of a given member within a struct +#[macro_export] +macro_rules! offsetof { + ($ty:ty, $field:ident) => { + unsafe { &(*(0 as *const $ty)).$field as *const _ as usize } + } +}