How to pass a class by (const) reference to C++
Jan
Jan at Krassnigg.de
Wed Dec 15 15:20:18 UTC 2021
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 unlike 'shared'
> tells the compiler "I know how to synchronize it myself".
>
> ```d
> module a;
>
> struct Foo {}
>
> extern(C++)
> __gshared Foo globalFoo;
> ```
Yeah, did that. As I said the mangled name that DMD chose is
correct.
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 someone who worked on
fixing lots of those issues a while ago and he immediately knew
about this limitation.
More information about the Digitalmars-d-learn
mailing list