小编moh*_*tux的帖子

Go中float64和complex128类型的最大值

我需要知道golang中float64和complex128变量类型的最大值.go似乎没有float.h的等价物,我不知道如何计算它.

variables floating-point go

6
推荐指数
1
解决办法
2万
查看次数

从 C++ 调用 Rust 时如何通过引用传递参数?

我正在尝试进行一个非常简单的测试,以了解如何从 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 …

c++ rust

0
推荐指数
1
解决办法
202
查看次数

标签 统计

c++ ×1

floating-point ×1

go ×1

rust ×1

variables ×1