我需要知道golang中float64和complex128变量类型的最大值.go似乎没有float.h的等价物,我不知道如何计算它.
我正在尝试进行一个非常简单的测试,以了解如何从 C/C++ 调用 Rust 函数。
我的 C++ 代码:
#include <iostream>
#include <cstdint>
extern "C" {
int32_t add_one(int32_t x);
} // extern "C"
using namespace std;
int main() {
int32_t x = 14;
cout << x << endl;
cout << add_one(x) << endl;
cout << x << endl;
}
Run Code Online (Sandbox Code Playgroud)
我的锈代码:
#[no_mangle]
pub extern "C" fn add_one(x: i32) -> i32 {
x + 1
}
Run Code Online (Sandbox Code Playgroud)
编译到一个库,这给出了一个.dll和一个.d文件来编译:
g++ main.c libc_rust.a -o output.exe
Run Code Online (Sandbox Code Playgroud)
正如我所料,这给了我14 15 14.
如何让我的 Rust …