Is there any way one can interface with Rust, such as with a struct, or a function?
I know that rust has an extern keyword, but I can't get it to work.
Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
September 29, 2022 Interfacing with Rust | ||||
---|---|---|---|---|
| ||||
Is there any way one can interface with Rust, such as with a struct, or a function? I know that rust has an extern keyword, but I can't get it to work. |
September 29, 2022 Re: Interfacing with Rust | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ruby The Roobster | On Thursday, 29 September 2022 at 16:02:43 UTC, Ruby The Roobster wrote: >Is there any way one can interface with Rust, such as with a struct, or a function? I know that rust has an extern keyword, but I can't get it to work. https://code.dlang.org/packages/rust_interop_d Read the notes on memory management: Only pass pointers as u64 as value type. |
September 30, 2022 Re: Interfacing with Rust | ||||
---|---|---|---|---|
| ||||
Posted in reply to mw | On Thursday, 29 September 2022 at 16:07:59 UTC, mw wrote: >On Thursday, 29 September 2022 at 16:02:43 UTC, Ruby The Roobster wrote: >Is there any way one can interface with Rust, such as with a struct, or a function? I know that rust has an extern keyword, but I can't get it to work. https://code.dlang.org/packages/rust_interop_d Read the notes on memory management: Only pass pointers as u64 as value type. This isn't the issue. I can't interface anything, period. |
September 30, 2022 Re: Interfacing with Rust | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ruby The Roobster | On Friday, 30 September 2022 at 00:18:42 UTC, Ruby The Roobster wrote: >On Thursday, 29 September 2022 at 16:07:59 UTC, mw wrote: >On Thursday, 29 September 2022 at 16:02:43 UTC, Ruby The Roobster wrote: >Is there any way one can interface with Rust, such as with a struct, or a function? I know that rust has an extern keyword, but I can't get it to work. https://code.dlang.org/packages/rust_interop_d Read the notes on memory management: Only pass pointers as u64 as value type. This isn't the issue. I can't interface anything, period. Show an example of exactly what you're trying to do. Maybe it's some detail |
October 01, 2022 Re: Interfacing with Rust | ||||
---|---|---|---|---|
| ||||
Posted in reply to Imperatorn | On Friday, 30 September 2022 at 06:25:33 UTC, Imperatorn wrote: >On Friday, 30 September 2022 at 00:18:42 UTC, Ruby The Roobster wrote: >On Thursday, 29 September 2022 at 16:07:59 UTC, mw wrote: >On Thursday, 29 September 2022 at 16:02:43 UTC, Ruby The Roobster wrote: >Is there any way one can interface with Rust, such as with a struct, or a function? I know that rust has an extern keyword, but I can't get it to work. https://code.dlang.org/packages/rust_interop_d Read the notes on memory management: Only pass pointers as u64 as value type. This isn't the issue. I can't interface anything, period. Show an example of exactly what you're trying to do. Maybe it's some detail lib.rs:
main.d:
lib.rs was built as a "staticlib" using rustc, and the command I used was: ldc2 -m64 main.d lib.lib The output:
Also, is it normal for the .lib file to be 11 megabytes? |
October 01, 2022 Re: Interfacing with Rust | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ruby The Roobster | extern(C++)? Why do you think Rust export C++ linkage? And why do you think Rust export some kind of OO object model linkage? Do it in plain C style, you may make it work. As said, check how it's done in: |