[Issue 22604] New: Linking against a C++ const array doesn't work
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 16 19:45:52 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22604
Issue ID: 22604
Summary: Linking against a C++ const array doesn't work
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: jan at krassnigg.de
Using this C++ class:
```
struct Test
{
__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};
```
And this D declaration:
```
extern(C++) struct Test
{
extern export static __gshared const(int)[2] const_vars;
extern export static __gshared int[2] nonconst_vars;
}
```
You CAN access 'nonconst_vars' just fine, but you CAN'T access 'const_vars'.
DMD wants to link against:
?const_vars at Test@@2PAHB
which is:
public: static int * const Test::const_vars
MSVC exports:
?const_vars at Test@@2QBHB
which is:
public: static int const * const Test::const_vars
So far I haven't found a way to work around this, so accessing constant arrays
seems to be impossible at the moment.
--
More information about the Digitalmars-d-bugs
mailing list