[Issue 23837] importc fails to link on windows x86 but successes on x64
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 24 22:52:24 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23837
--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> ---
The `__init{struct name}` symbol is generated as the initializer for a struct
by the dmd.tocsym.toInitializer() function. It is inserted into the object file
generated for the source file with the struct definition in it. Hence,
dmd -m32 main.d
will fail to link, because the object file for test.c is not linked in. To fix,
dmd -m32 main.d test.c
So why does the former still work on other platforms? If the struct is zero
initialized, a section in the BSS segment of all zeros is used instead. But the
relocations for BSS do not work for MSCOFF-32.
Since C structs are always default initialized to zero, a better solution would
be to initialize the instance with code rather than copying zero'd data to it.
--
More information about the Digitalmars-d-bugs
mailing list