-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zig Bindgen - references #1
Comments
Very interesting! I will give a look into it but I'm maily interested in c++ one of my ideas with c2z is to have a copy of the memory model of c++ classes and structures in the zig side so we can just access them without the need to use opaque pointers |
Making it shorter, it is a possible alternative: - extern fn @"_Z9enumerateRNSt3__16vectorIhNS_9allocatorIhEEEEm"(out_buf: *cpp.Vector(u8), count: usize) bool;
- pub const enumerate = @"_Z9enumerateRNSt3__16vectorIhNS_9allocatorIhEEEEm";
+ pub const enumerate = @extern(*const fn (out_buf: *cpp.Vector(u8), count: usize) bool, .{ .name = "_Z9enumerateRNSt3__16vectorIhNS_9allocatorIhEEEEm" }); I remember partially translating a C solution for demangling C++ and Rust functions. Original project used in mold linker is updated to v0 mangling, not C++ compatible. https://github.com/kassane/rsDemangle-zig (legacy mangling, c++ compatible) based in old gist version. |
Mangling for
|
Previously I've been working with cbindgen which transpiles rust code into other languages, commonly used for C. However I've added zig support.
During this experiment I realized that zig can read mangled functions in both C++ and Rust (in the same way as c++filt) with the help of lld it can demangling functions (linked to libc++ + libunwind).
The best thing is the possibility of static linking in libraries written in these languages. (e.g. incubator-opendal w/ zig binding and zFFI)
Another Reference
The text was updated successfully, but these errors were encountered: