Quellcode durchsuchen

Initial commit: Hello FFI in Rust!

Lucas Stadler vor 10 Jahren
Ursprung
Commit
416aa59f35
4 geänderte Dateien mit 18 neuen und 0 gelöschten Zeilen
  1. 1 0
      rust/coffi/.gitignore
  2. 4 0
      rust/coffi/Cargo.lock
  3. 4 0
      rust/coffi/Cargo.toml
  4. 9 0
      rust/coffi/src/main.rs

+ 1 - 0
rust/coffi/.gitignore

@ -0,0 +1 @@
1
/target

+ 4 - 0
rust/coffi/Cargo.lock

@ -0,0 +1,4 @@
1
[root]
2
name = "coffi"
3
version = "0.1.0"
4

+ 4 - 0
rust/coffi/Cargo.toml

@ -0,0 +1,4 @@
1
[package]
2
name = "coffi"
3
version = "0.1.0"
4
authors = ["Lucas Stadler <lu@papill0n.org>"]

+ 9 - 0
rust/coffi/src/main.rs

@ -0,0 +1,9 @@
1
#[link(name = "m")]
2
extern {
3
    fn cos(d: f64) -> f64;
4
}
5
6
fn main() {
7
    let x = unsafe { cos(3.1415) };
8
    println!("cos(3.1415) = {}", x);
9
}