Skip to content

Instantly share code, notes, and snippets.

@geofft
Last active September 2, 2015 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geofft/493c5c17bfdd04b97670 to your computer and use it in GitHub Desktop.
Save geofft/493c5c17bfdd04b97670 to your computer and use it in GitHub Desktop.
#[no_mangle] is unsafe
extern crate b;
extern crate c;
fn main() {
println!("{} {}", b::identity(), c::identity());
}
#![crate_type="lib"]
#[no_mangle]
pub fn identity() -> &'static str {
"b"
}
#![crate_type="lib"]
#[no_mangle]
pub fn identity() -> &'static str {
"c"
}
geofft@titan:/tmp/libparty$ rustc b.rs
geofft@titan:/tmp/libparty$ rustc c.rs
geofft@titan:/tmp/libparty$ rustc a.rs -L .
geofft@titan:/tmp/libparty$ ./a
b b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment