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

Tim tim.dlang at
Wed Dec 15 22:33:15 UTC 2021

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, no? Also why the `export` when 
> it's an extern variable?

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, like `__declspec(dllexport)` 
in C++. `export` and `extern` combined imports the variable, like 

More information about the Digitalmars-d-learn mailing list