

CXX库提供Rust和C+ 之间的安全相互调用
source link: https://www.jdon.com/59476
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

CXX库提供Rust和C+ 之间的安全相互调用
CXX库提供了一种安全的机制,用于从 Rust 调用 C++ 代码和从 C++ 调用 Rust 代码。它开辟了一个共性机制,其中 Rust 和 C++ 在语义上非常相似,并指导程序员在这个机制内有效地表达他们的语言边界。
CXX 填充了低级别的东西,以便您获得安全的绑定,防止在不安全的 C 样式签名上执行外部函数接口的陷阱。
从语言边界的高级描述来看,CXX 使用类型和函数签名的静态分析来保护 Rust 和 C++ 的不变量。然后它使用一对代码生成器在两侧有效地实现边界以及任何必要的静态断言,以便稍后在构建过程中验证正确性。
由此产生的 FFI 桥以零或可忽略的开销运行,即无需复制、无需序列化、无需内存分配、无需运行时检查。
cxx在FaceBook等大规模生产中已经使用。
可被用于制作安全的 QT,rust-qt 的方法和示例 :https://github.com/rust-qt/examples
当你构建了一个 rust 库,而你的二进制文件根本不是由 rust 驱动的。rust cxx-qt 提供了由链接在 rust 库中的 c++ 主驱动程序驱动;
但rust-qt 方法更好,因为您可以使用“cargo build --release”来构建基于 rust 的 qt gui。
最重要的是,使用 rust-qt 绑定,您的主要驱动程序是 rust,
Recommend
-
135
C和Lua之间的相互调用 第一次接触Lua是因为Unity游戏...
-
32
ES5 没有定义文件之间引用方式,在浏览器中文件之间引用需要通过类似 define , require , __webpack_require__ 这样的全局变量,它们由不同的模块化框架定义。 ES Modules 从标准上定义...
-
15
CXX — safe FFI between Rust and C++ This library provides a safe mechanism for calling C++ code from Rust and Rust code from C++, not subject to the many ways that things can go wrong when usin...
-
8
Safe Interoperability between Rust and C++ with CXX Dec 06, 2020...
-
4
因为临时发现需要一个枚举量到字符串的转换器,所以干脆梳理了一遍古往今来的枚举类型的变化。 于是奇怪的冷知识又增加了。 枚举类型
-
9
At KDAB, we have been investigating how to integrate Rust with Qt in a safe and idiomatic way. The solution we are currently working on is called CXX-Qt. It’s available in the
-
7
序言Permalink 很早以前,我有计划要为 GTD 做一个定时报闹的库,原因在于大多数现在的 GTD 软件、TODO、行...
-
5
Introducing `cxx-async` Patrick Walton · August 19, 2022 Update 9/6/2022: Fixed a potential use-after-free on the C++ side if the future got dropped. Thanks to David Tolnay for poin...
-
1
将 []T 切片转换为 []byte 类似C语言中将其他类型的数组转换为char数组: func ByteSlice(slice interface{}) (data []byte) { sv := reflect.ValueOf(slice) if sv.Kind() != reflect.Sl...
-
11
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK