mirror of
https://github.com/guilhermewerner/rust-ffi
synced 2025-06-16 13:54:19 +00:00
Add Sample Functions to Library
This commit is contained in:
@ -10,7 +10,7 @@ publish = false
|
|||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name="Library"
|
name="Library"
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
path = "Source/Library.rs"
|
path = "Source/Library.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
pub fn Hello() {
|
#![allow(dead_code)]
|
||||||
println!("Hello Library");
|
#![allow(unused_variables)]
|
||||||
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Add(num1: f32, num2: f32) -> f32 {
|
||||||
|
return num1 + num2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Subtract(num1: f32, num2: f32) -> f32 {
|
||||||
|
return num1 - num2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Multiply(num1: f32, num2: f32) -> f32 {
|
||||||
|
return num1 * num2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Divide(num1: f32, num2: f32) -> f32 {
|
||||||
|
return num1 / num2;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user