Rust lang

2 января 2021, 23:13
Rorschach
0
151

1. PowerShell

cargo new calc --lib

2. Cargo.toml

[lib]
crate-type = ["dylib"]

3. lib.rs

#[no_mangle]
pub extern "stdcall" fn double_input(input: i32) -> i32 {    // "stdcall" ?
    input * 2
}

4. PowerShell

cargo build --release

5. MetaEditor

#property script_show_inputs
#import "calc.dll"
   int double_input(int a);
#import

input int num=2;

void OnStart()
  {
   Print(calc::double_input(num));
  }

https://www.mql5.com/en/docs/runtime/imports

https://doc.rust-lang.org/reference/items/external-blocks.html#abi

https://doc.rust-lang.org/reference/linkage.html

https://www.mql5.com/ru/forum/625/page33#comment_1444052

https://dev.to/living_syn/calling-rust-from-c-6hk

https://habr.com/ru/post/257687/