macro_rules! global {
    (
        $(
            $vs:vis extern $name:ident: $fty:ty = $lib_name:tt$sep:tt$var:tt$([$add:tt])?;
        )*
    ) => { ... };
}
Expand description

Creates global that resolves its address on the first access.

global! {
    // Explicitly defined RVA offset relative to `01-hello` module.
    extern COUNT: i32 = "01-hello.exe"@0x1234;
}
// On `get` the value of type `i32` will be read at address `base("01-hello.exe") + 0x1234`.
// COUNT also implements `AsRef` and `AsMut` traits but be careful because these methods can cause crash because they don't require unsafe block.
assert_eq!(COUNT.get(), 123);