I just wanted to declare a pointer to a struct in a crate shared by several components of my project but using the same process. I mean the aim is to get it initialized only once.
type Box = [u64; 64];
pub static mut mmaped: &mut Box;
which at compile time generated this error.
free static item without body
Where mmaped
is later assigned a value in the following way only one time from the top crate and it s value used from the multiple crates it depends on.
mmaped = unsafe { std::mem::transmute(addr) };
So how do I provide a definition of mmaped
without having to mmap
it more than one time?
This question isn't a duplicate of How do I create a global, mutable singleton?, as it doesn't talk about exporting the singleton outside the crate and I'm getting a compiler error specifically for doing it.