From 89085ce699c6111f11afc85fee5b1dfd51d8fc21 Mon Sep 17 00:00:00 2001 From: GuilhermeWerner Date: Thu, 21 Jan 2021 12:35:08 -0300 Subject: [PATCH] Add Sample Functions to Library --- Cargo.toml | 2 +- Source/Library.rs | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0e2ee82..0846764 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ publish = false [lib] name="Library" -crate-type = ["cdylib"] +crate-type = ["staticlib", "cdylib", "rlib"] path = "Source/Library.rs" [dependencies] diff --git a/Source/Library.rs b/Source/Library.rs index 208ebd8..0256e09 100644 --- a/Source/Library.rs +++ b/Source/Library.rs @@ -1,3 +1,23 @@ -pub fn Hello() { - println!("Hello Library"); +#![allow(dead_code)] +#![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; }