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

--- Comment #13 from Walter Bright <bugzi...@digitalmars.com> ---
In this case, ModuleInfo is how the D runtime runs static constructors.
Programs compiled with betterC are meant to link only with the C runtime
library, which knows nothing about ModuleInfo.

The problem here is writing a library that is compiled with betterC, and meant
to be linked with either a betterC program or a D program.

Simply turning off ModuleInfo generation means the betterC's library does not
run its static constructors.

Since a D program that is importing betterC modules does not know if they are
betterC modules or not, it is the betterC modules' responsibility to choose how
to do its own static construction.

I.e. a betterC module should use the following to run its static construction:

    pragma(crt_constructor) extern (C) void doMyStaticConstruction() { ... }

If a betterC is to be only linked with a D main, it should do:

    static this() { ... }

It should not do both, as then the static constructions will get run twice if
it is linked with a D main.

The change to fix this bug report, then, is for betterC modules to generate a
ModuleInfo if it has a `static this` constructor. And to add these instructions
to the documentation.

The DLL export stuff is an orthogonal problem.

--

Reply via email to