Skip to content

Instantly share code, notes, and snippets.

@retep998
Last active April 15, 2019 22:45
Show Gist options
  • Save retep998/808ad305508486b7743ec44444f15b65 to your computer and use it in GitHub Desktop.
Save retep998/808ad305508486b7743ec44444f15b65 to your computer and use it in GitHub Desktop.
#![crate_type = "dylib"]
pub const FOO: &str = "FOO";
pub static BAR: &str = "BAR";
#![crate_type = "dylib"]
extern crate a;
pub fn doit() {
println!("b const {:?}", a::FOO as *const str);
println!("b static {:?}", a::BAR as *const str);
}
#![crate_type = "dylib"]
extern crate a;
pub fn doit() {
println!("c const {:?}", a::FOO as *const str);
println!("c static {:?}", a::BAR as *const str);
}
extern crate b;
extern crate c;
fn main() {
b::doit();
c::doit();
}
> rustc a.rs -Cprefer-dynamic; rustc b.rs -L.; rustc c.rs -L.; rustc d.rs -L.; ./d.exe
b const 0x7ffdfd2821b0
b static 0x7ffdf6552150
c const 0x7ffdfe4f21b0
c static 0x7ffdf6552150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment