[Issue 22367] The __ModuleInfo member spuriously linked for modules compiler with -betterC

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 30 08:25:59 UTC 2022


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

--- Comment #9 from Walter Bright <bugzilla at digitalmars.com> ---
Iain has the right idea. The solution is to, when in -betterC mode:

1. automatically annotate static constructors with:

    pragma(crt_constructor) extern (C)

2. do the same for static destructors

3. not set `needmoduleinfo` for (1) and (2)

This will run the constructors and destructors using the C runtime library
mechanism. The downside of this is the order of construction and destruction
will be in the order the object files are seen by the linker, rather than a
depth-first hierarchical order.

----

Mathias' suggestion is a good one. Give an error on `static this()`, and only
work with `shared static this()`.

--


More information about the Digitalmars-d-bugs mailing list