Re: Interfacing with basic C++ class

2022-09-29 Thread Riccardo M via Digitalmars-d-learn
On Wednesday, 28 September 2022 at 20:41:13 UTC, Ali Çehreli wrote: [...] Ali Thank you, that is perfect! However that begs the following observation: it would be rather hard to link to a C++ library only by means of 'extern (C++)' if one should slightly rearrange C++ code as well. This

Re: importC and cmake

2022-09-29 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 28 September 2022 at 06:04:36 UTC, zjh wrote: On Wednesday, 28 September 2022 at 05:29:41 UTC, Chris Piker wrote: `Xmake` is indeed simpler. `Xmake` is really nice! zjh Sorry to go off topic for a moment, but do you happen to know how to tell xmake that my project is C

Re: importC and cmake

2022-09-29 Thread zjh via Digitalmars-d-learn
On Thursday, 29 September 2022 at 20:56:50 UTC, Chris Piker wrote: ```lua set_languages("c99") ``` Try: `add_cxflags` or `add_files("src/*.c")` or `set_languages("c")` or `set_languages("c11")` . or ,use `-l` to set language. ```cpp xmake create -l c -t static test ```

Re: Interfacing with Rust

2022-09-29 Thread Ruby The Roobster via Digitalmars-d-learn
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.

Re: Interfacing with basic C++ class

2022-09-29 Thread Ogi via Digitalmars-d-learn
On Wednesday, 28 September 2022 at 19:57:10 UTC, Riccardo M wrote: I think I am stuck in the easiest of the issues and yet it seems I cannot get around this. I have a C++ file: ``` class MyClass { public: int field; MyClass(int a) : field(a) {} int add(int asd) { return asd

Re: Interfacing with basic C++ class

2022-09-29 Thread Ali Çehreli via Digitalmars-d-learn
On 9/29/22 01:28, Riccardo M wrote: > if one should > slightly rearrange C++ code as well. Right. Additionally, the order of members must match (I am pretty sure, which means I am not :p). > I am a recent addition to D > language :) Welcome! :) > Do you know that this is documented

Re: Interfacing with basic C++ class

2022-09-29 Thread Riccardo M via Digitalmars-d-learn
On Thursday, 29 September 2022 at 11:13:15 UTC, Ogi wrote: Ali is correct. However, you don’t have to change anything on the C++ side, just map C++ class to D struct: [...] Thanks, this works perfectly. Now i see that I can even instantiate directly from D, calling the default ctor, calling

Interfacing with Rust

2022-09-29 Thread Ruby The Roobster via Digitalmars-d-learn
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.

Re: Interfacing with Rust

2022-09-29 Thread mw via Digitalmars-d-learn
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