[Issue 22335] New: Exporting variables from DLLs is unusable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Sep 25 12:07:51 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22335
Issue ID: 22335
Summary: Exporting variables from DLLs is unusable
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: maxsamukha at gmail.com
dll.d:
module dll;
export __gshared int x = 41;
extern(Windows) int DllMain(void*, uint, void*)
{
return 1;
}
----
client.d:
module client;
import dll;
void main()
{
assert(x == 41); // fails. x refers to garbage
}
----
dmd -m64 -shared dll.d
dmd -m64 client.d dll.lib
client.exe
'dmd -m64 -H -o- dll.d' emits the definition instead of declaration, so using
the interface file is not an option either.
The only way to make this work is to manually change the definition in the .di
file to the declaration ('extern export __gshared int x'), which is
impractical.
--
More information about the Digitalmars-d-bugs
mailing list