Re: Is there a place I can learn LLD inline assembly with GCC syntax?

2021-12-15 Thread rempas via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 21:57:39 UTC, Johan wrote: The wiki page you linked to describes LDC's own inline assembly syntax, which supports all targets but is no longer recommended. If you want GCC-style inline assembly, it's probably best to have a look at GCC's documentation: https:

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Jan via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 22:50:38 UTC, Tim wrote: On Wednesday, 15 December 2021 at 22:46:01 UTC, Jan wrote: Btw. should I report this issue somewhere? Is far as I see this isn't logged yet: Yes, it should b

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Tim via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 22:46:01 UTC, Jan wrote: Btw. should I report this issue somewhere? Is far as I see this isn't logged yet: Yes, it should be reported.

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Jan via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 22:33:15 UTC, Tim wrote: I agree that __gshared should imply static. That's probably a bug in the compiler. Using `extern` without `export` would only work with static linking (on Windows). `export` without `extern` would be exporting the variable for others,

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Tim via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 22:01:19 UTC, Jan wrote: Ha, it works indeed! ```cpp extern export __gshared static int var; ``` That's a declaration worthy of C++ ! Fewer keywords would be too usable :D Joking aside, I understood the docs such that `__gshared` actually *is* `static` in D

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Adam Ruppe via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 22:24:42 UTC, H. S. Teoh wrote: `__gshared` is needed to coax the compiler into making the variable global in the C/C++ sense, i.e., only 1 instance across all threads. it is just normally __gshared implies static automatically. it does in like every other c

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Dec 15, 2021 at 10:01:19PM +, Jan via Digitalmars-d-learn wrote: > On Wednesday, 15 December 2021 at 21:30:47 UTC, Tim wrote: [...] > ```cpp > extern export __gshared static int var; > ``` [...] > Joking aside, I understood the docs such that `__gshared` actually > *is* `static` in D, n

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Jan via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 21:30:47 UTC, Tim wrote: It seems to work if var is additionally static: Ha, it works indeed! ```cpp extern export __gshared static int var; ``` That's a declaration worthy of C++ ! Fewer keywords would be too usable :D Joking aside, I understood the docs

Re: Is there a place I can learn LLD inline assembly with GCC syntax?

2021-12-15 Thread Johan via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 09:26:28 UTC, rempas wrote: I want to learn how to use inline assembly for LDC with GCC syntax specifically so I can support all the targets (as [here](https://wiki.dlang.org/Compilers) it is said that DMD intel-like syntax only supports the "i386" and "amd64"

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Tim via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 19:28:44 UTC, Jan wrote: C++ ```cpp class Test { public: __declspec(dllexport) static int var; }; int Test::var = 42; ``` D ```cpp extern(C++, class) struct Test { extern (C++) export extern __gshared int var; } ``` (also tried without the duplicate extern

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Jan via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 17:10:51 UTC, Tim wrote: Do you have a test case for your problem? C++ ```cpp class Test { public: __declspec(dllexport) static int var; }; int Test::var = 42; ``` D ```cpp extern(C++, class) struct Test { extern (C++) export extern __gshared int var; } `

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Tim via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 15:20:18 UTC, Jan wrote: As I was told linking against functions in DLLs works perfectly, because it is identical to static linking. Linking against global/static variables supposedly differs and that's not handled correctly for DLLs. As I said, I talked to som

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Jan via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 12:36:49 UTC, evilrat wrote: You probably know this but just in case - unlike C++ in D variables by default have thread local storage, to link with C++ global variable you need to use __gshared storage modifier in D, it is similar to 'shared' variable that unli

Re: How to define property type to Array!struct?

2021-12-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/15/21 9:41 AM, Stanislav Blinov wrote: On Wednesday, 15 December 2021 at 11:36:41 UTC, Manfred Nowak wrote: On Tuesday, 14 December 2021 at 08:28:01 UTC, WebFreak001 wrote: [...] Alternatively, remove the template `()` from your `struct Header` What is the semantic sense of a template h

Re: How to define property type to Array!struct?

2021-12-15 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 11:36:41 UTC, Manfred Nowak wrote: On Tuesday, 14 December 2021 at 08:28:01 UTC, WebFreak001 wrote: [...] Alternatively, remove the template `()` from your `struct Header` What is the semantic sense of a template having no parameters? Although the documentati

Re: How to define property type to Array!struct?

2021-12-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/15/21 6:36 AM, Manfred Nowak wrote: On Tuesday, 14 December 2021 at 08:28:01 UTC, WebFreak001 wrote: [...] Alternatively, remove the template `()` from your `struct Header` What is the semantic sense of a template having no parameters? Although the documentation declares such a template

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 10:54:45 UTC, Jan wrote: Someone with more in-depth knowledge told me, that Windows support in D and specifically DLL support is lacking quite a bit. gdc and ldc have the same full support you'd expect coming from microsoft c++. dmd doesn't though. You can

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread evilrat via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 12:02:08 UTC, Jan wrote: On Wednesday, 15 December 2021 at 11:03:27 UTC, rikki cattermole wrote: On 15/12/2021 11:54 PM, Jan wrote: On Wednesday, 15 December 2021 at 09:36:54 UTC, Jan wrote: Unfortunately it's the "annoying little details" that I immediately

Re: How to define property type to Array!struct?

2021-12-15 Thread bauss via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 11:36:41 UTC, Manfred Nowak wrote: On Tuesday, 14 December 2021 at 08:28:01 UTC, WebFreak001 wrote: [...] Alternatively, remove the template `()` from your `struct Header` What is the semantic sense of a template having no parameters? Although the documentati

Re: How to define property type to Array!struct?

2021-12-15 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 11:36:41 UTC, Manfred Nowak wrote: On Tuesday, 14 December 2021 at 08:28:01 UTC, WebFreak001 wrote: [...] Alternatively, remove the template `()` from your `struct Header` What is the semantic sense of a template having no parameters? Although the documentati

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Jan via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 11:03:27 UTC, rikki cattermole wrote: On 15/12/2021 11:54 PM, Jan wrote: On Wednesday, 15 December 2021 at 09:36:54 UTC, Jan wrote: Unfortunately it's the "annoying little details" that I immediately bumped into. Just another example: I just learned that lin

Re: How to define property type to Array!struct?

2021-12-15 Thread Manfred Nowak via Digitalmars-d-learn
On Tuesday, 14 December 2021 at 08:28:01 UTC, WebFreak001 wrote: [...] Alternatively, remove the template `()` from your `struct Header` What is the semantic sense of a template having no parameters? Although the documentation declares such a template to be syntactically correct, not a single

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread rikki cattermole via Digitalmars-d-learn
On 15/12/2021 11:54 PM, Jan wrote: On Wednesday, 15 December 2021 at 09:36:54 UTC, Jan wrote: Unfortunately it's the "annoying little details" that I immediately bumped into. Just another example: I just learned that linking against C++ DLLs is quite limited. I ran into the issue that linki

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Jan via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 09:36:54 UTC, Jan wrote: Unfortunately it's the "annoying little details" that I immediately bumped into. Just another example: I just learned that linking against C++ DLLs is quite limited. I ran into the issue that linking in an external variable doesn't wo

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Jan via Digitalmars-d-learn
On Tuesday, 14 December 2021 at 07:50:48 UTC, evilrat wrote: There is some missing features like above tail ref and const, there is minor mangling issues that requires pragma mangle sometimes, and other annoying little details. As far as I can tell from my limited experience, the way D approa

Is there a place I can learn LLD inline assembly with GCC syntax?

2021-12-15 Thread rempas via Digitalmars-d-learn
I want to learn how to use inline assembly for LDC with GCC syntax specifically so I can support all the targets (as [here](https://wiki.dlang.org/Compilers) it is said that DMD intel-like syntax only supports the "i386" and "amd64" targets) but I cannot find anything other [this](https://wiki