December 15, 2021

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

That's all very helpful, thanks for the explanations guys.

Btw. should I report this issue somewhere? Is far as I see this isn't logged yet:
https://issues.dlang.org/buglist.cgi?quicksearch=c%2B%2B%20extern%20static

December 15, 2021

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:
https://issues.dlang.org/buglist.cgi?quicksearch=c%2B%2B%20extern%20static

Yes, it should be reported.

December 15, 2021

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:
https://issues.dlang.org/buglist.cgi?quicksearch=c%2B%2B%20extern%20static

Yes, it should be reported.

https://issues.dlang.org/show_bug.cgi?id=22603

December 16, 2021

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:
https://issues.dlang.org/buglist.cgi?quicksearch=c%2B%2B%20extern%20static

Yes, it should be reported.

Ok, next problem. Maybe you know the necessary syntax for this one too.

C++

class Test
{
public:
  __declspec(dllexport) static const int const_vars[2];
  __declspec(dllexport) static int nonconst_vars[2];
};

const int Test::const_vars[2] = {11, 23};
int Test::nonconst_vars[2] = {12, 24};

D

extern(C++, class) struct Test
{
    extern export static __gshared const(int)[2] const_vars;
    extern export static __gshared int[2] nonconst_vars;
}

I get the nonconst_vars to link correctly, but for the const_vars the mangled name contains one less const than what MSVC generates, so I assume I have to wrap this somehow differently. I tried "const(int[2])" but that didn't make a difference.

D wants to link against:
?const_vars@Test@@2PAHB

which is:
public: static int * const Test::const_vars" ()

MSVC exports:
?const_vars@Test@@2QBHB

which is:
public: static int const * const Test::const_vars

Any idea?

December 16, 2021

On Thursday, 16 December 2021 at 08:30:14 UTC, Jan wrote:

>

Ok, next problem. Maybe you know the necessary syntax for this one too.

C++

class Test
{
public:
  __declspec(dllexport) static const int const_vars[2];
  __declspec(dllexport) static int nonconst_vars[2];
};

const int Test::const_vars[2] = {11, 23};
int Test::nonconst_vars[2] = {12, 24};

D

extern(C++, class) struct Test
{
    extern export static __gshared const(int)[2] const_vars;
    extern export static __gshared int[2] nonconst_vars;
}

I get the nonconst_vars to link correctly, but for the const_vars the mangled name contains one less const than what MSVC generates, so I assume I have to wrap this somehow differently. I tried "const(int[2])" but that didn't make a difference.

D wants to link against:
?const_vars@Test@@2PAHB

which is:
public: static int * const Test::const_vars" ()

MSVC exports:
?const_vars@Test@@2QBHB

which is:
public: static int const * const Test::const_vars

Any idea?

That looks like another bug in the compiler. pragma(mangle, ...) should work as a workaround.

December 16, 2021

On Thursday, 16 December 2021 at 16:21:30 UTC, Tim wrote:

>

That looks like another bug in the compiler. pragma(mangle, ...) should work as a workaround.

Another bug ticket it is then:
https://issues.dlang.org/show_bug.cgi?id=22604

1 2 3 4
Next ›   Last »