mirror of
https://git.proxmox.com/git/proxmox
synced 2025-07-05 12:07:57 +00:00
proxmox-tools/src/lib.rs: implement offsetof
This commit is contained in:
parent
b243d9664d
commit
d7fbee66e3
@ -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 }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user